C++ – itoa function problem


I'm working on Eclipse inside Ubuntu environment on my C++ project.

I use the itoa function (which works perfectly on Visual Studio) and the compiler complains that itoa is undeclared.

I included <stdio.h>, <stdlib.h>, <iostream> which doesn't help.

Best Solution

www.cplusplus.com says:

This function is not defined in ANSI-C and is not part of C++, but is supported by some compilers.

Therefore, I'd strongly suggest that you don't use it. However, you can achieve this quite straightforwardly using stringstream as follows:

stringstream ss;
ss << myInt;
string myString = ss.str();