Skip to main content
gamedev.net
🔒 Locked

sprintf question

Started by hello_there Jan 30, 2003 at 10:59 PM 3 replies 250+ views
Original Post
hello_there
hello_there
you know how sprintf(numbers, " %0.17f", somenumber); converts it so you can print it useing a char. can you do it the other way and convert letters to numbers?
____________How could hell be worse?
mmelson
mmelson
Look for strtol and strtod. Those work for converting strings into longs and doubles (respectively).

Mike
eldee
eldee
sprintf only changes char arrays, so no.
you''re looking for itoa().

int tempint;
itoa(tempint, string, base); // where base is 8, 10, or 16

-eldee
;another space monkey;
[ Forced Evolution Studios ]

::evolve::

Do NOT let Dr. Mario touch your genitals. He is not a real doctor!

deadlydog
deadlydog
Actually I think the function you are looking for is atoi, not itoa. itoa converts an int to a char, atoi converts a char to an int, which is what I believe you are looking for.

- Dan
He who laughs, lasts

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.