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++....
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++....
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Use sscanf (in C) or an istringstream (in C++) instead