![]() |
strtol | Function (tigcc.a) |
stdlib.h |
long strtol (const char *str, char **endptr, short radix); |
Converts a string to a long integer using a given radix, with detection of overflows and errors.
strtol converts a character string str to a long integer value. str is a
sequence of characters that can be interpreted as a long value. The characters must match this
generic format:
[ws] [sn] [0] [x] [ddd]
where
First character | Second character | String interpreted as |
0 0 1 - 9 |
1 - 7 x or X |
Octal Hexadecimal Decimal |
Value in str meant to be interpreted as | Resulting Character Recognition |
Octal | Any character other than 0 to 7 will be unrecognized. |
Decimal | Any character other than 0 to 9 will be unrecognized. |
A number in any other base | Only the numerals and letters used to represent numbers in that base will be recognized (for example, if radix equals 5, only 0 to 4 will be recognized; if radix equals 20, only 0 to 9 and A to J will be recognized). |