strtol [ HP C/iX Library Reference Manual ] MPE/iX 5.0 Documentation
HP C/iX Library Reference Manual
strtol
Converts a string to a long integer value.
Syntax
#include <stdlib.h>
long strtol (const char *str, char **ptr, int base);
Parameters
str A pointer to a character string to be converted. If base
is set to zero, leading characters in str define the
conversion. After an optional leading sign, a leading zero
indicates octal conversion, and a leading "0x" or "0X"
indicates hexadecimal conversion. Otherwise, decimal
conversion is used.
ptr If ptr is not NULL, a pointer to the character terminating
the scan is stored in the object pointed to by ptr.
base If base is between 2 and 36, it is used as the base for
conversion. After an optional leading sign, leading zeros
are ignored, and "0x" or "0X" is ignored if base is 16. If
base is set to zero, the string itself determines the base.
Return Values
x If successful, a long integer value.
0 Indicates failure unless the value pointed to by str is
zero.
* If *ptr is set to str, no number can be formed.
* If *ptr is greater than str, the value pointed to by
*str is zero.
LONG_MAX The conversion would cause an overflow; errno is set to
ERANGE.
LONG_MIN The conversion would cause an underflow; errno is set to
ERANGE.
Description
The strtol function returns as a long integer the value represented by
the character string pointed to by str. The string is scanned up to the
first character inconsistent with base. Leading white-space characters
(as defined by the isspace function) are ignored.
See Also
strtod(), strtoul(), atof(), ANSI C 4.10.1.5
MPE/iX 5.0 Documentation