STRTOL(3) BSD Programmer's Manual STRTOL(3)
s
\bst
\btr
\brt
\bto
\bol
\bl,
\b, s
\bst
\btr
\brt
\bto
\boq
\bq - convert string value to a long or quad_t integer
S
\bSY
\bYN
\bNO
\bOP
\bPS
\bSI
\bIS
\bS
#
\b#i
\bin
\bnc
\bcl
\blu
\bud
\bde
\be <
\b<s
\bst
\btd
\bdl
\bli
\bib
\bb.
\b.h
\bh>
\b>
#
\b#i
\bin
\bnc
\bcl
\blu
\bud
\bde
\be <
\b<l
\bli
\bim
\bmi
\bit
\bts
\bs.
\b.h
\bh>
\b>
s
\bst
\btr
\brt
\bto
\bol
\bl(_
\bc_
\bh_
\ba_
\br _
\b*_
\bn_
\bp_
\bt_
\br, _
\bc_
\bh_
\ba_
\br _
\b*_
\b*_
\be_
\bn_
\bd_
\bp_
\bt_
\br, _
\bi_
\bn_
\bt _
\bb_
\ba_
\bs_
\be);
#
\b#i
\bin
\bnc
\bcl
\blu
\bud
\bde
\be <
\b<s
\bsy
\bys
\bs/
\b/t
\bty
\byp
\bpe
\bes
\bs.
\b.h
\bh>
\b>
#
\b#i
\bin
\bnc
\bcl
\blu
\bud
\bde
\be <
\b<s
\bst
\btd
\bdl
\bli
\bib
\bb.
\b.h
\bh>
\b>
#
\b#i
\bin
\bnc
\bcl
\blu
\bud
\bde
\be <
\b<l
\bli
\bim
\bmi
\bit
\bts
\bs.
\b.h
\bh>
\b>
s
\bst
\btr
\brt
\bto
\boq
\bq(_
\bc_
\bh_
\ba_
\br _
\b*_
\bn_
\bp_
\bt_
\br, _
\bc_
\bh_
\ba_
\br _
\b*_
\b*_
\be_
\bn_
\bd_
\bp_
\bt_
\br, _
\bi_
\bn_
\bt _
\bb_
\ba_
\bs_
\be);
D
\bDE
\bES
\bSC
\bCR
\bRI
\bIP
\bPT
\bTI
\bIO
\bON
\bN
The s
\bst
\btr
\brt
\bto
\bol
\bl() function converts the string in _
\bn_
\bp_
\bt_
\br to a _
\bl_
\bo_
\bn_
\bg value. The
s
\bst
\btr
\brt
\bto
\boq
\bq() function converts the string in _
\bn_
\bp_
\bt_
\br to a _
\bq_
\bu_
\ba_
\bd_
\b__
\bt value. The
conversion is done according to the given _
\bb_
\ba_
\bs_
\be, 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 (as deter-
mined by isspace(3)) followed by a single optional `+' or `-' sign. If
_
\bb_
\ba_
\bs_
\be is zero or 16, the string may then include a `0x' prefix, and the
number will be read in base 16; otherwise, a zero _
\bb_
\ba_
\bs_
\be is taken as 10
(decimal) unless the next character is `0', in which case it is taken as
The remainder of the string is converted to a _
\bl_
\bo_
\bn_
\bg value in the obvious
manner, stopping at the first character which is not a valid digit in the
given base. (In bases above 10, the letter `A' in either upper or lower
case represents 10, `B' represents 11, and so forth, with `Z' represent-
If _
\be_
\bn_
\bd_
\bp_
\bt_
\br is non nil, s
\bst
\btr
\brt
\bto
\bol
\bl() stores the address of the first invalid
character in _
\b*_
\be_
\bn_
\bd_
\bp_
\bt_
\br. If there were no digits at all, however, s
\bst
\btr
\brt
\bto
\bol
\bl()
stores the original value of _
\bn_
\bp_
\bt_
\br in _
\b*_
\be_
\bn_
\bd_
\bp_
\bt_
\br. (Thus, if _
\b*_
\bn_
\bp_
\bt_
\br is not `\0'
but _
\b*_
\b*_
\be_
\bn_
\bd_
\bp_
\bt_
\br is `\0' on return, the entire string was valid.)
R
\bRE
\bET
\bTU
\bUR
\bRN
\bN V
\bVA
\bAL
\bLU
\bUE
\bES
\bS
The s
\bst
\btr
\brt
\bto
\bol
\bl() function returns the result of the conversion, unless the
value would underflow or overflow. If an underflow occurs, s
\bst
\btr
\brt
\bto
\bol
\bl() re-
turns LONG_MIN. If an overflow occurs, s
\bst
\btr
\brt
\bto
\bol
\bl() returns LONG_MAX. In both
cases, _
\be_
\br_
\br_
\bn_
\bo is set to ERANGE.
[ERANGE] The given string was out of range; the value converted has been
S
\bSE
\bEE
\bE A
\bAL
\bLS
\bSO
\bO
atof(3), atoi(3), atol(3), strtod(3), strtoul(3)
S
\bST
\bTA
\bAN
\bND
\bDA
\bAR
\bRD
\bDS
\bS
The s
\bst
\btr
\brt
\bto
\bol
\bl() function conforms to ANSI C X3.159-1989 (``ANSI C '').
Ignores the current locale.