Link to home
Start Free TrialLog in
Avatar of thanesh
thanesh

asked on

how to use itoa() function

Hi Experts,

I was using
#include <iostream.h>
#include <stdlib.h>

void main()
{

char *charValue = "123";
int value;
value = atoi(charValue);
cout << value << endl;
value = 256;

char buff[5];
itoa( value, buff, 10 );         <<<<-----

cout << buff << endl;

}

I am getting the error "itoa" unknown identifier.  But, I included the correct header file, I guess..  So, what is wrong.... I am running it in Linux. using g++....
Avatar of e_tadeu
e_tadeu

itoa is not ANSI-C
Use sscanf (in C) or an istringstream (in C++) instead
SOLUTION
Avatar of e_tadeu
e_tadeu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial