Int to char array conversion - any suggestions
simple question here
how can I convert:
int Integer = 64;
into
char String[3] = "64";
Im trying to set up a stats shower for my game. I wrote a custom font engine which only accepts character arrays. I''ve tried it with numbers as its fields, so I know that that part of it will work. I just need to convert the integer that my fps function generates into a character array.
thanks;
Prairie
Use sprintf, like so:
int Integer = 64;char String[10];sprintf(String,"%i",Integer);
Morbo is right... that will work...
Optionally, you could use itoa()...
that last parameter tells itoa what base to use... 2 for binary, 10 for decimal, 16 for hex, etc.
remember to include stdlib.h if you're gonna use it tho!
~Morkhai
Edited by - Morkhai on July 18, 2000 12:40:13 PM
Optionally, you could use itoa()...
itoa(Integer, String, 10);
that last parameter tells itoa what base to use... 2 for binary, 10 for decimal, 16 for hex, etc.
remember to include stdlib.h if you're gonna use it tho!
~Morkhai
Edited by - Morkhai on July 18, 2000 12:40:13 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement