Advertisement

i just can't believe i don't remember this....

Started by June 08, 2002 11:58 PM
3 comments, last by jasonf 22 years, 8 months ago
too much time spent on 3d maths and not enough on simple c i guess ;( anyway guys, heres the problem.... i''ve got an integer (65) that i have to store as a string as an ascii character, in this case, an A. 66 would be B etc... I thought itoa would work, but that just gave me "65" not "A". is there an itos? if so, i don''t seem to have it, or can''t find a reference for it... please help me with this o so lame question... thanks in advance...
Jason FeserCode Geek / Visuals Guyelasticmediaproductionshttp://www.elasticvisuals.com
I''ve never coded in C before, but I''m pretty sure you just need to do some type-casting:

(char) 65

I *think* . I always get excited when it looks like a c question that I might be able to answer, so if this is wrong, then... oh well . If I had a compiler I would check for you now.
Trying is the first step towards failure.
Advertisement
Dunno if that would work, but that''s what I''d guess too. Also, I think creating a variable of type char and assigning the number to it would work too. The type cast is probably a better method though, assuming it works.
Peon
char in c (inherently unsigned) is nothing but a number from 0 to 255 ... only when printed it is interpreted as a character.
just remember to end your string with a zero byte (if youre actually going to use it with string functions).

cheers

Thanks..

Got it. I have a nice little one line doskey style console working in my app. Took me most of yesterday but whatever...

I just gotta say that this forum rocks!

:j
Jason FeserCode Geek / Visuals Guyelasticmediaproductionshttp://www.elasticvisuals.com

This topic is closed to new replies.

Advertisement