Definition | #include <stdlib.h> int atol(const char *s);
All control characters for white space are legal for tab (see definitiona at The | |
Return val. | Integer value of type | |
for strings formatted as described above and representing a numeric value that lies in the permissible range of integers. | ||
0 | for strings which do not correspond to the syntax described above. | |
|
| |
| in the case of an overflow, depending on the sign. | |
Notes |
| |
Example | The following program converts a string passed in the call (Enter Options) into the corresponding floating-point number. #include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
/* Numbers are passed as a string!!
A conversion is required if the
numeric value is needed. */
{
printf("long integer : %ld\n", atol(argv[1]));
return 0;
}
| |
See also | atof, atoi, atoll, strtod, strtol, strtoll, strtoul, strtoull | |