version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
STRTOL |
|
|
2 |
!!!STRTOL |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
RETURN VALUE |
|
|
7 |
ERRORS |
|
|
8 |
CONFORMING TO |
|
|
9 |
SEE ALSO |
|
|
10 |
BUGS |
|
|
11 |
---- |
|
|
12 |
!!NAME |
|
|
13 |
|
|
|
14 |
|
|
|
15 |
strtol - convert a string to a long integer. |
|
|
16 |
!!SYNOPSIS |
|
|
17 |
|
|
|
18 |
|
|
|
19 |
__#include |
|
|
20 |
__''nptr''__, char **__''endptr''__, int__ ''base''__); |
|
|
21 |
__ |
|
|
22 |
!!DESCRIPTION |
|
|
23 |
|
|
|
24 |
|
|
|
25 |
The __strtol()__ function converts the string in |
|
|
26 |
''nptr'' to a long integer value according to the given |
|
|
27 |
''base'', which must be between 2 and 36 inclusive, or be |
|
|
28 |
the special value 0. |
|
|
29 |
|
|
|
30 |
|
|
|
31 |
The string must begin with an arbitrary amount of white |
|
|
32 |
space (as determined by isspace(3)) followed by a |
|
|
33 |
single optional `+' or `-' sign. If ''base'' is zero or |
|
|
34 |
16, the string may then include a `0x' prefix, and the |
|
|
35 |
number will be read in base 16; otherwise, a zero |
|
|
36 |
''base'' is taken as 10 (decimal) unless the next |
|
|
37 |
character is `0', in which case it is taken as 8 |
|
|
38 |
(octal). |
|
|
39 |
|
|
|
40 |
|
|
|
41 |
The remainder of the string is converted to a long int value |
|
|
42 |
in the obvious manner, stopping at the first character which |
|
|
43 |
is not a valid digit in the given base. (In bases above 10, |
|
|
44 |
the letter `A' in either upper or lower case represents 10, |
|
|
45 |
`B' represents 11, and so forth, with `Z' representing |
|
|
46 |
35.) |
|
|
47 |
|
|
|
48 |
|
|
|
49 |
If ''endptr'' is not NULL, __strtol()__ stores the |
|
|
50 |
address of the first invalid character in ''*endptr''. If |
|
|
51 |
there were no digits at all, __strtol()__ stores the |
|
|
52 |
original value of ''nptr'' in ''*endptr'' (and returns |
|
|
53 |
0). In particular, if ''*nptr'' is not `0' but |
|
|
54 |
''**endptr'' is `0' on return, the entire string is |
|
|
55 |
valid. |
|
|
56 |
!!RETURN VALUE |
|
|
57 |
|
|
|
58 |
|
|
|
59 |
The __strtol()__ function returns the result of the |
|
|
60 |
conversion, unless the value would underflow or overflow. If |
|
|
61 |
an underflow occurs, __strtol()__ returns LONG_MIN. If an |
|
|
62 |
overflow occurs, __strtol()__ returns LONG_MAX. In both |
|
|
63 |
cases, ''errno'' is set to ERANGE. |
|
|
64 |
!!ERRORS |
|
|
65 |
|
|
|
66 |
|
|
|
67 |
__ERANGE__ |
|
|
68 |
|
|
|
69 |
|
|
|
70 |
The given string was out of range; the value converted has |
|
|
71 |
been clamped. |
|
|
72 |
!!CONFORMING TO |
|
|
73 |
|
|
|
74 |
|
|
|
75 |
SVID 3, BSD 4.3, ISO 9899 |
|
|
76 |
!!SEE ALSO |
|
|
77 |
|
|
|
78 |
|
|
|
79 |
atof(3), atoi(3), atol(3), |
|
|
80 |
strtod(3), strtoul(3) |
|
|
81 |
!!BUGS |
|
|
82 |
|
|
|
83 |
|
|
|
84 |
Ignores the current locale. |
|
|
85 |
---- |