Author Topic: missing itoa in stdlib.h  (Read 7527 times)

creek23

  • Guest
missing itoa in stdlib.h
« on: June 05, 2011, 09:28:18 am »
is there any other option to convert an int to string? :(

~creek23

borus

  • Posts: 54
Re: missing itoa in stdlib.h
« Reply #1 on: June 05, 2011, 09:47:50 am »
Implement itoa yourself ?
E.g. like here.

creek23

  • Guest
Re: missing itoa in stdlib.h
« Reply #2 on: June 05, 2011, 09:54:37 am »
that's pretty much what I was gonna do. I was just hoping there was some kind of implementation in Dingoo SDK.

~creek23

pcercuei

  • Posts: 1728
    • My devblog
Re: missing itoa in stdlib.h
« Reply #3 on: June 05, 2011, 10:43:04 am »
sprintf() is the default C function to transform numbers into a string.

djdron

  • Posts: 33
Re: missing itoa in stdlib.h
« Reply #4 on: June 07, 2011, 09:41:31 am »
http://www.cplusplus.com/reference/clibrary/cstdlib/itoa/

Portability
This function is not defined in ANSI-C and is not part of C++, but is supported by some compilers.

A standard-compliant alternative for some cases may be sprintf:
sprintf(str,"%d",value) converts to decimal base.
sprintf(str,"%x",value) converts to hexadecimal base.
sprintf(str,"%o",value) converts to octal base.