Declaration:
long strtol(char s[], int endptr[], int radix, int index=0);
Converts an ASCII-string (the s parameter; index specifies shift in the line) into a long number. The radix parameter is the radix used for conversion (2...36).
String s may include the following components:
[ws] [sn] [0] [x] [ddd]
[ws] - Optional spaces or tabulation symbols
[sn] - Optional sign (+ or -)
[0] - Optional zero (0)
[x] - Optional x or X
- Optional digits
endptr array contains that character number).
If radix is equal to 0, then radix will be selected by the first few characters of the s string:
First character Second character String interpretation
0 1 - 7 Octal
0 x or X Hexadecimal
1 - 9 Decimal
Returned value
The converted long integer number.
|