Converting from integer value to character?

Started by
5 comments, last by Zeraan 21 years, 8 months ago
I''m working on this little message thing for my game, and I stumbled across my first obstacle. How do I convert int into char? I don''t want if/else like if i % 10 = 9 then c = ''9''. I want this: DrawMessage("SomeMessage"); DrawMessage(someIntVariable); Is this even possible? If so, then I want to do this also: DrawMessage("SomeMessage" + someIntVariable);
Advertisement
Look up the ''sscanf()'' function or the ''stringstream'' class.

-D
Pardon me. I meant the ''itoa()'' rather than ''sscanf()''.

-D
Ah thanks, this helped me a lot!
none of those things should work, as they make char ARRAYS.
Naaah use sprintf instead:

sprintf(yourchar,"%d",yourint);
Darkhaven Beta-test stage coming soon.
quote:none of those things should work, as they make char ARRAYS.


What making a string out of say 25 is bad? Do you have another way of doing it?

This topic is closed to new replies.

Advertisement