stupid atoi() problem

Started by
3 comments, last by zackriggle 21 years, 3 months ago
Alright, somebody please tell me why this is not producing "14fc3". itoa("14fc3"); Thanks
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
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?
If you''re trying to do what I think you are, use strtol.

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)''.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.

This topic is closed to new replies.

Advertisement