• Advertisement

Archived

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

converting an int to a char

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

i have a score that i want to be able to convert to a char array so i can read through it one by one to see which bitmap to put on the screen. does anyone know how to do this?

Share this post


Link to post
Share on other sites
Advertisement
char scorestring[256];
int score;
sprintf(scorestring,"%d",score);

Share this post


Link to post
Share on other sites
quote:
Original post by Mithoric
char buff[10];
itoa ( score,buff,10 );

Two problems: 1) itoa() is a non-standard function. 2) the buffer you allocated is inadequate, if the integer value is 1,000,000,000 or greater, the terminating null will smash the stack.

Share this post


Link to post
Share on other sites

  • Advertisement