Jump to content
  • Advertisement

Archived

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

Anonymous0

Int To String (char*)

This topic is 6014 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
itoa(int, char*, int)

first int is the int to convert to char.
char* is the buffer to put the converted string into.
the second int is the number base to convert the int from. Base 10 for stanard numbers. Base 2 for binary, base 8 for oct, base 16 for hex.

Share this post


Link to post
Share on other sites
Radix is what base you want your number to be viewed as.

IE, base 10 is decimal, 16 is hexidecimal, 8 is octal.


- Houdini

Share this post


Link to post
Share on other sites
radix is the number base.

radix = 2; would for binary numbers. base 2.
radix = 10; would be for decimal numbers. base 10.
radix = 16; would be for hexadecimal numbers. base 16.

etc. etc.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post


Link to post
Share on other sites
Just for further info, there is a whole slew of conversion functions that follow a standard format.

atoi is basically a char to int function (a is for char)


There''s also an itoa function (int to char)
atof function (char to float)
ftoa function (float to char)
l for long
d for double
etc.

Share this post


Link to post
Share on other sites
you can also use:

char szNumber[16];
int nNumber = 1234567890;
sprintf(szNumber,"%d",nNumber);

and actualy, "a" stands for ASCII



Edited by - kwizatz on January 29, 2002 1:21:02 PM

Share this post


Link to post
Share on other sites
using snprintf is safer than sprintf (which should be banned IMHO).

Watch those buffer overflows people, that''s how security holes are created ! Learn to do it right from the beginning.

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!