Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Fuzztrek

Converting numbers to "characters"

This topic is 5792 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

hello all, I''m creating D3D game, and I''m checking the display mode to make sure that the user supports the mode. However, if the test fails i would like to display a message box showing the values that were tested. However, I do not know these values as they are passed through a function. I want to be able to show these values that were passed through the function as a string int he message box, however, since i can''t convert the numeral values to characters, i can''t add them to a string to print etc. How would i convert them? is there some easy functiont hat will do it all for me? (:D)? Thanks!! Fuzztrek ¬_¬

Share this post


Link to post
Share on other sites
Advertisement
You can use the itoa() function or what I do, just use sprintf() eg:

int val;
// do something
char errorstring[50];
sprintf(errorstring, "The value tested was %d", val);
cout << errorstring << endl;

very simple...

CEO Platoon Studios

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The itoa function is non-standard. Just use snprintf, or sprintf if you must, or stringstream in C++.

Share this post


Link to post
Share on other sites
ah.. i feel stupid. i saw that numerous times but didn''t really look into it.... are programers, like mathmaticians, lazy? maybe i''m the only one.

thanks soooo much!!!!

¬_¬

Share this post


Link to post
Share on other sites

  • 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!