Click to See Complete Forum and Search --> : Converting a string to int


April 25th, 1999, 03:28 AM
Hi,
I have the variable char temp[8].
With this variable the user can enter a single character
or an 8 digit number.
When the user enters an 8 digit number I need to be able to convert
the variable into an int variable.
Does anyone know how to do this.

Prasutagus
April 25th, 1999, 06:34 AM
You can use the standard C++ function 'atoi()' to convert a from char to int. In your case this would look something like this :

char temp[8];


... user entry stuff ...
int result = atoi(temp);



Good Luck, Pras

April 26th, 1999, 12:07 AM
Thanks
it worked