Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
strtol(3) OSS Library Calls Reference Manual
NAME
strtol - Converts a character string to a signed long integer
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zcrtldll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/ycrtldll
SYNOPSIS
#include <stdlib.h>
long int strtol (
const char *nptr,
char **endptr,
int base);
PARAMETERS
nptr Points to the character string to convert.
endptr Points to a pointer in which the function stores the position in the string specified
by the nptr parameter where a character is found that is not a valid character for
the purpose of this conversion.
base Specifies the radix to use for the conversion.
DESCRIPTION
The strtol( ) function converts the initial portion of the character string pointed to by the nptr
parameter to a long integer representation. The input character string is first broken down into
three parts:
white space An initial (possibly empty) sequence of spaces (as specified by the isspace( )
function for the C/POSIX locale and the iswspace( ) function for other locales)
subject sequence
A sequence of characters that are valid in an integer constant of the radix deter-
mined by the base parameter
unrecognized characters
A final sequence of unrecognized character codes, including the terminating null
character
If possible, the subject is then converted to an integer and the result is returned.
The base parameter can take values of 0 or between 2 and 36:
• If the base value is 0 (zero), the subject string can be a decimal, octal, or hexadecimal
integer constant. A decimal constant begins with a nonzero digit, and consists of a
sequence of decimal digits. An octal constant consists of the prefix 0 (zero) optionally
followed by a sequence of digits in the range 0 through 7. A hexadecimal constant con-
sists of the prefix 0x or 0X followed by a sequence consisting of decimal digits and the
letters in the range a or A to f or F.
6−184 Hewlett-Packard Company 527187-017