I've a simple code – this works on other platforms but does not work in ubuntu.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int x=99;
char str[100];
itoa(99, str, 10);
return 0;
}
Trying to compile in using terminal in gcc with :
gcc test.c
But I get the error:
/tmp/ccJN77g6.o: In function `main':
test.c:(.text+0x35): undefined reference to `itoa'
collect2: ld returned 1 exit status
Why so? prototype for itoa is included in stdlib.h
Best Answer
itoa
doesn't seem to be ANSI C++ and thus is very likely to be not supported by gcc.According to this source, a the following workaround is suggested:
A
sprintf
reference can be found here.