Your Browser is not longer supported
Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...
{{viewport.spaceProperty.prod}}
atoi - convert string to integer
&pagelevel(4)&pagelevel
Syntax | #include <stdlib.h> int atoi(const char *str); |
Description | atoi() converts an EBCDIC string to which str points into an integer. The string to be converted may be formatted as follows: [{ tab | 'BLANK' }...] [+|-] digit ...
All characters that produce white space are legal for tab (see isspace() ). The atoi(str) function differs from strtol(str,(char**)NULL) only in error handling. |
Return val. | Integer value of type int |
|
| for strings formatted as described above and representing a numeric value that lies in the permissible range of integers. |
| 0 | for strings that do not conform to the syntax described above. |
| INT_MAX or INT_MIN
|
|
| in the case of an overflow, depending on the sign. |
Notes | atoi() is completely contained in strtol() . However, the function continues to be offered because it is used in many existing applications.
atoi() also recognizes strings that begin with digits but then end with any character. atoi() cuts off the numeric part, converts it according to the above description, and ignores the rest.
|
See also | atof() , atol() , strtod() , strtol() , strtoul() , stdlib.h .
|