K & R:
long strtol(const char *s, char **endp, int base)
strtol converts the prefix of s to long, ignoring leading white
space; it stores a pointer to any unconverted suffix in *endp
unless endp is NULL. If base is between 2 and 36, conversion is
done assuming that the input is written in that base. If base is
zero, the base is 8, 10, or 16; leading 0 implies octal and leading
0x or 0X hexadecimal. Letters in either case represent digits from
10 to base-1; a leading 0x or 0X is permitted in base 16. If the
answer would overflow, LONG_MAX or LONG_MIN is returned, depending
on the sign of the result, and errno is set to ERANGE.