用这个函数:(stdlib.h中)
long strtol(const char *s, char **endptr, int radix);
对参数radix的解释:
If radix is between 2 and 36, the long integer is expressed in base radix. If radix is 0, the first few characters of s determine the base of the value being converted.
First character Second character String interpreted as...
0 1 - 7 Octal
0 x or X Hexadecimal
1 - 9 Decimal
If radix is 1, it is considered to be an invalid value. If radix is less than 0 or greater than 36, it is considered to be an invalid value.
Any invalid value for radix causes the result to be 0 and sets the next character pointer *endptr to the starting string pointer.