Dingoonity.org

Dingoo Official Firmware => Development => Topic started by: creek23 on June 05, 2011, 09:28:18 am

Title: missing itoa in stdlib.h
Post by: creek23 on June 05, 2011, 09:28:18 am
is there any other option to convert an int to string? :(

~creek23
Title: Re: missing itoa in stdlib.h
Post by: borus on June 05, 2011, 09:47:50 am
Implement itoa yourself ?
E.g. like here (http://www.daniweb.com/software-development/cpp/threads/189996).
Title: Re: missing itoa in stdlib.h
Post by: creek23 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
Title: Re: missing itoa in stdlib.h
Post by: pcercuei on June 05, 2011, 10:43:04 am
sprintf() is the default C function to transform numbers into a string.
Title: Re: missing itoa in stdlib.h
Post by: djdron 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.