Guardian Native C Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

Guardian Native C Library Calls (s) strtol(3)
} else {
/* retval contains long integer */
printf("Integer in decimal is %d\n", retval);
}
}
}
RETURN VALUES
The strtol() function returns the converted value of long integer if the expected form is found. If
no conversion could be performed, a value of 0 (zero) is returned. If the converted value is out-
side the range of representable values, LONG_MAX or LONG_MIN is returned (according to
the sign of the value).
If the endptr parameter is not a null pointer, the function stores a pointer to the final sequence of
unrecognized characters in the object pointed to by endptr except when the subject sequence is
empty or invalid. In this case, the function stores the nptr pointer in the object pointed to by the
endptr parameter.
Because this function returns 0 (zero), LONG_MIN,orLONG_MAX in the event of an error
and these values are also valid returns if the function is successful, applications should set errno
to 0 (zero) before calling this function, and check errno after return from the function. If errno
is nonzero, an error occurred.
Additionally, if 0 (zero) is returned, applications should check if the endptr parameter equals the
nptr parameter. In this case, there was no valid subject string.
ERRORS
If any of the following conditions occurs, the strtol() function sets errno to the corresponding
value:
[EINVAL] The base parameter has a value less than 0 (zero), equal to 1, or greater than 36.
[ERANGE] The converted value is outside the range of representable values.
If nptr is NULL, the function returns 0 (zero) and does not set errno.
RELATED INFORMATION
Functions: atof(3), atoi(3), atol(3), scanf(3), strtoll(3), strtoul(3), strtoull(3), scanf(3),
wstol(3).
STANDARDS CONFORMANCE
The behavior of this function conforms to the Single UNIX Specification, Version 3 and the 1999
ANSI C standard.
527192-018 Hewlett-Packard Company 6135