Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

that's my question. I've Gcc 4.4.1 and that function isn’t present, i had installed the 4.3 and 4.5 versions with the same result :-/

I know that this function is not the C-ANSI standard, but I didn't write the code and I need compile it in my distro. A friend of mine had the same version of the compiler in Fedora, and Gcc compiles with no problem (using stdio.h and stdlib.h).

So if someone can tell me if the function is/isn't available in my compiler.. I'd be thankful.


btw: this my gcc version:

:~$ gcc -v
Using built-in specs.
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.4-14ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5
share|improve this question

It doesn't appear to be defined in 4.4.4, but if you don't care about radixes other than 10

char *itoa(long i, char* s, int dummy_radix) {
    sprintf(s, "%ld", i);
    return s;

Is a quick and dirty (and tested) replacement.

share|improve this answer
Sounds like they want to compile a software package that uses the function – Stefano Palazzo Dec 17 '10 at 6:07
And their suite lacks the function which one would need to compile it. So there is the function ready for linking. Am i missing some subtle point you are trying to make? – msw Dec 17 '10 at 10:26
thank for the hand stefano, i had used another function similar to yours. Greetings. – Rcart Dec 18 '10 at 4:58
 void itoa(int n, char s[])
 int i, sign;

 if ((sign = n) < 0)  /* записываем знак */
     n = -n;          /* делаем n положительным числом */
 i = 0;
 do {       /* генерируем цифры в обратном порядке */
     s[i++] = n % 10 + '0';   /* берем следующую цифру */
 } while ((n /= 10) > 0);     /* удаляем */
 if (sign < 0)
     s[i++] = '-';
 s[i] = '\0';

And if you need the reverse function:

#include <string.h>

/* reverse:  переворачиваем строку s на месте */
void reverse(char s[])
 int i, j;
 char c;

 for (i = 0, j = strlen(s)-1; i<j; i++, j--) {
     c = s[i];
     s[i] = s[j];
     s[j] = c;

I have got this implementation from the Russian Wikipaedia.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.