Stdlib itoa function
I searched on internet and saw a lot of code that uses itoa() function & they claimed that this function is in stdlib.h
I'm using 2 versions of GCC right now:
(GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4))
(GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)
and both of them does not have itoa() function (I compile the program & error: undefined reference to `itoa').
Any i开发者_StackOverflow中文版deas? Thanks.
itoa()
isn't in standard C - snprintf()
is the function to use in its place (at least it's probably the simplest change to make).
Wikipedia gives you an explanation: it's a non standard function, but compilers often provide it through the header <stdlib.h>
while in non-conforming mode.
Here is good article regarding this problem starting from phrase "How do I use itoa() with GCC?". Article also provides several itoa() implementations with even performance comparison, please take a look.
精彩评论