This function is not defined in ANSI-C and is not part of C++, but is supported by some compilers.
ajh32's code above does not compile on C++ Shell (including either <stdlib.h> or <cstdlib>)
In function 'int main()': 7:24: error: 'itoa' was not declared in this scope
But if you're compiler does support itoa (or ltoa)...
You need to include the stdlib header in your program:
If compiling as .cpp could include <cstdio> instead.
And stack space isn't that limited, so no need to use as tight a buffer as possible.
1 2 3 4 5 6 7 8 9 10 11
#include <iostream>
#include <cstdlib> // now using C++ header
int main()
{
int value = 100;
char buffer[32] = ""; // plenty of space (and zero init)
itoa(value, buffer, 10); // no actual need to take address of first elem
std::cout << buffer << "\n";
return 0;
}