atoi
int atoi ( const char * string ); | stdlib.h |
cplusplus.com |
Convert string to integer.
Parses string interpreting its content as a number and returns an int value.
Parameters.
Return Value.
The converted integer value of the input string.
On overflow the result is undefined.
If an error occurs 0 is returned.
Portability.
Defined in ANSI-C.
Example.
/* atoi example */
#include <stdio.h>
#include <stdlib.h>
main ()
{
int i;
char szInput [256];
printf ("Enter a number: ");
gets ( szInput );
i = atoi (szInput);
printf ("Value entered is %d, and its double %d",i,i*2);
return 0;
}
Output:
Enter a number: 73
Value entered is 73, and its double 146
See also.
atof,
atol,
ecvt,
fcvt,
gcvt,
strtod