.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\" This code is derived from software contributed to Berkeley by
.\" Chris Torek and the American National Standards Committee X3,
.\" on Information Processing Systems.
.\" %sccs.include.redist.man%
.\" @(#)strtol.3 8.1 (Berkeley) %G%
.Nd convert string value to a long or quad_t integer
.Fn strtol "char *nptr" "char **endptr" "int base"
.Fd #include <sys/types.h>
.Fn strtoq "char *nptr" "char **endptr" "int base"
The conversion is done according to the given
which must be between 2 and 36 inclusive,
or be the special value 0.
The string may begin with an arbitrary amount of white space
followed by a single optional
the string may then include a
and the number will be read in base 16; otherwise, a zero
is taken as 10 (decimal) unless the next character is
in which case it is taken as 8 (octal).
The remainder of the string is converted to a
value in the obvious manner,
stopping at the first character which is not a valid digit
(In bases above 10, the letter
in either upper or lower case
represents 11, and so forth, with
stores the address of the first invalid character in
If there were no digits at all, however,
stores the original value of
on return, the entire string was valid.)
returns the result of the conversion,
unless the value would underflow or overflow.
The given string was out of range; the value converted has been clamped.
Ignores the current locale.