Advertisement

Converting numbers to "characters"

Started by September 07, 2002 08:19 PM
3 comments, last by Fuzztrek 22 years, 3 months ago
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 ¬_¬
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
[email=esheppard@gmail.com]esheppard@gmail.com[/email]
Advertisement
itoa()
The itoa function is non-standard. Just use snprintf, or sprintf if you must, or stringstream in C++.
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!!!!

¬_¬

This topic is closed to new replies.

Advertisement