• Advertisement

Archived

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

sprintf question

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

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?

Share this post


Link to post
Share on other sites
Advertisement
Look for strtol and strtod. Those work for converting strings into longs and doubles (respectively).

Mike

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

  • Advertisement