STRTOL(S) XENIX System V STRTOL(S)
Name
strtol, atol, atoi - Converts string to integer.
Syntax
long strtol (str, ptr, base)
char *str, **ptr;
int base;
long atol (str)
char *str;
int atoi (str)
char *str;
Description
strtol returns as a long integer the value represented by
the character string pointed to by str. This routine scans
the string up to the first character inconsistent with the
base. It ignores leading white space characters as defined
by isspace (see ctype(S)).
If the value of ptr is not (char **)0, strtol returns a
pointer to the character terminating the scan at the
location pointed to by ptr. If no integer can be formed,
that location is set to str, and strtol returns zero.
base is used as the base for conversion if it is positive
and not greater than 36. If base is 16, leading zeros are
ignored after an optional leading sign, and ``0x'' or ``0X''
is ignored. If base is zero, the string determines the base
in the following manner: a leading xero indicates octal
conversion after an optional leading sign; a leading ``0x''
or ``0X'' indicates hexadecimal conversion; in other cases,
decimal conversion is used.
Truncation from long to int can take place upon assignment
or by explicit cast.
atol(str) is equivalent to strtol(str, (char**)0, 10).
atoi(str) is equivalent to (int) strtol(str, (char**)0, 10).
Page 1 (printed 8/7/87)
STRTOL(S) XENIX System V STRTOL(S)
See Also
ctype(S), scanf(S), strtod(S)
Notes
Overflow conditions are ignored.
Page 2 (printed 8/7/87)