从控制台读取后,我试图打印一个特别大的值。当我尝试从两种不同的方式打印它时,一种是在分配后直接打印,一种是使用strtol
函数的返回值,我得到不同的输出!有人可以解释一下为什么我注意到两个不同的输出吗?
输入值为:4294967290
这是代码片段。
long int test2 = strtol(argv[1], &string, 10);
printf("the strtol value is %ld\n", test2);
printf("the strtol function value is %ld\n", strtol(argv[1], &string, 10));
输出
the strtol value is -6
the strtol function value is 4294967290