1,字符串转整型(一)
#include
int atoi(const char *nptr);
字符串转化为整型
long atol(const char *nptr);
字符串转化为长整型
long long atoll(const char *nptr);
long long atoq(const char *nptr);
字符串转化为long long 类型
英文手册很简单,直接上
说明:The atoi() function converts the initial portion of the string pointed to by nptr to int. The behavior is the same as strtol(nptr, (char **) NULL, 10); except that atoi() does not detect errors. The atol() and atoll() functions behave the same as atoi(), except that they convert the initial portion of the string to their return type of long or long long. atoq() is an obsolete name for atoll().
2,字符串转整型(二)
#include
long int strtol(const char *nptr, char **endptr, int base);
字符串转长整型,base参数为进制,如转化为10进制,则base应该为10
long long int strtoll(const char *nptr, char **endptr, int base);
字符串转化为long long int
说明:详细说明请参考man手册。