Jump to content
  • Advertisement

Archived

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

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

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

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...

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!