tags:

views:

474

answers:

3

Hi,

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:

  1. (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4))

  2. (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 ideas? Thanks.

+6  A: 

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).

Michael Burr
+3  A: 

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.

luvieere
A: 

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.

Roman Nikitchenko