strtol溢出的解决办法

extern char* pszValue ;

//strtol只能返回带符号的整数,如果pszValue是个无符号数,且值 > 0x7FFFFFFF,返回值为0x7FFFFFF ,即-1;
int nValue = strtol(pszValue ,NULL,16);

//可以通过如下的方式解决这个问题。

int nValue = strtoul(pszValue ,NULL,16);

参考:https://blog.csdn.net/xidwong/article/details/3981000

https://baike.baidu.com/item/strtol/6134558?fr=aladdin

https://blog.csdn.net/tajon1226/article/details/47128255?utm_source=blogxgwz0

https://baike.baidu.com/item/strtoul

猜你喜欢

转载自blog.csdn.net/dragoo1/article/details/84890105