Jump to content
  • Advertisement
Sign in to follow this  
Harryu

[SOLVED] wsprintf problems

This topic is 4383 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok. I am programming a 3D rpg in DirectX and C++. At the moment, I am experiencing a very annoying problem relating to the use of wsprintf. Basically, I call wsprintf like this: wsprintf(Text, "blahblahblah %d", Num); Which is how I think I'm meant to be doing it. The problem is, sometimes, as soon as the program reaches that point I get a non-responsive program error. It has happened many times throughout my game, and I've managed to find ways around it, but I can't think of a good way to get around this one. Especially when I don't even know what the problem is! So if anybody has any idea whatsoever what might cause wsprintf to cause my program to crash, please say so. Any help will be greatly appreciated. Harry [Edited by - Harryu on July 20, 2006 8:50:44 PM]

Share this post


Link to post
Share on other sites
Advertisement
The w at the beginning stands for "wide". The function expects it's arguments to be made of wide characters (ie. Unicode more or less).

wsprintf(Text, "blahblahblah %d", Num);

String literals are ansi. Try wrapping the format spec in a _T macro (or TEXT macro if you prefer).

For example:

wsprintf(Text, _T("blahblahblah %d"), Num);


Share this post


Link to post
Share on other sites
when I try that I get a compiler error:

_T identifier not found

EDIT: Solved. For some reason I had declared Text as a pointer rather than just an array of chars. I don't know why it was fixed when I changed it, but it did. I'd still sort of like to know what the problem was if anybody has some ideas.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!