2
回答
strtoul函数问题
【腾讯云】校园拼团福利,1核2G服务器10元/月!>>>   

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

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

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

<无标签>
举报
墨小盒
发帖于6年前 2回/739阅
共有2个答案 最后回答: 6年前
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).

--- 共有 2 条评论 ---
ChenQierrno 百度下 6年前 回复
墨小盒它说超出范围将会返回ULONG_MAX,并且 sets errno to ERANGE,error怎么查看呢? 6年前 回复
顶部