itoa depends on compiler, so better use the following methods :-
method 1 :If you are using c++11, just go for std::to_string. It will do the trick.
method 2 :sprintf works for both c & c++.
ex-
ex - to_string
#include <bits/stdc++.h>
using namespace std;
int main ()
{
int i;
char buffer [100];
printf ("Enter a number: ");
scanf ("%d",&i);
string str = to_string(i);
strcpy(buffer, str.c_str());
cout << buffer << endl;
return 0;
}
Note - compile using -std=c++0x.
C++ sprintf:
int main ()
{
int i;
char buffer [100];
printf ("Enter a number: ");
scanf ("%d",&i);
sprintf(buffer, "%d", i);
return 0;
}`