Jump to content
  • Advertisement

Archived

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

MARS_999

Strings and int values

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

Is their anyway to take a int value and convert it into a string so I can display the value as a string? I need it for scores to be displayed as text. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
itoa()

Share this post


Link to post
Share on other sites
_itoa <-- look it up

parameters are ( value, string, radix )
( radix = 10 for decimal, 2 binary and the such )

no error return, but be sure string is big enough to hold the result.


Edit: Don't forget to include stdlib.h




[edited by - zern on February 1, 2003 11:53:12 PM]

Share this post


Link to post
Share on other sites
Assuming C or C++, any itoa function is non-standard (even if it exists it isn''t guaranteed to work in even remotetly the same way, or do the same thing).

C: lookup sprintf or snprintf (the latter is prefered).
C++: lookup std::stringstream or boost::lexical_cast.

If you aren''t using C or C++, please specify the language you are using.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!