strtoul函数问题

墨小盒 发布于 2012/08/10 12:40
阅读 746
收藏 0

在使用strtoul函数把字符串转化为无符号长整型的时候,只能转化0-4294967295范围内的数,

unsigned long strtoul(const char *nptr,char **endptr,int base);

如果*nptr大于4294967295怎么办,如果检查这个数是不是大于它

加载中
0
中山野鬼
中山野鬼
自己写咯。。。或者看标准 7.22.1.4.
0
ChenQi
ChenQi
RETURN VALUE
       The strtoul() function returns either the result of the conversion or, if there was a leading minus sign, the negation of the result of the conversion represented as an unsigned value, unless the
       original (nonnegated) value would overflow; in the latter case, strtoul() returns ULONG_MAX and sets errno to ERANGE.  Precisely  the  same  holds  for  strtoull()  (with  ULLONG_MAX  instead  of
       ULONG_MAX).

ERRORS
       EINVAL (not in C99) The given base contains an unsupported value.

       ERANGE The resulting value was out of range.

       The implementation may also set errno to EINVAL in case no conversion was performed (no digits seen, and 0 returned).

ChenQi
ChenQi
errno 百度下
墨小盒
它说超出范围将会返回ULONG_MAX,并且 sets errno to ERANGE,error怎么查看呢?
返回顶部
顶部