Jump to content
  • Advertisement

Archived

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

zackriggle

stupid atoi() problem

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

Advertisement
Are you trying to use atoi() or itoa() ( Your subject and example are different ).


If you are trying to use itoa, don''t. Use something like sprintf() instead to go from integer to array.

-------
Andrew

Share this post


Link to post
Share on other sites
ahh fuck. im dumb (i did this in the post wrong, not in the code).

atoi("2134AFE");

Will produce the result 2134. Why is this? Should I use atol?

Share this post


Link to post
Share on other sites
I think hexidecimal digits are supposed to be prefixed with ''0x'', i.e., ''0x2134afe''. If it''s always supposed to input hexidecimal, use ''strtol("2134afe", 0, 16)''.

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!