strtol
我在 c 中遇到了一些不寻常的结果
这是示例程序。
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("%x\n", strtol("0xfffff70A", NULL, 0));
return 0;
}
这个简单程序的输出是
0x7fffffff
而不是0xfffff70A
. 如果我使用strtoul
,结果是完全正确的0xfffff70a
。我使用的是 32 位机器,我想知道会发生什么。PS。我正在使用 gcc 4.7.2