我在用代码锁。
下面是C语言中的程序:
/*to find the value of EOF ( End Of the File ) Number */
#include<stdio.h>
int main()
{
printf("The EOF value is: %d %5ld",EOF, EOF);
/*when EOF specified in %d specifier it is giving the value as -1, but if its
given %ld then a number 4294967295 is printed on the console?*/
return 0;
}
正如我在节目的评论中所说:
我在惠普上使用64位Linux操作系统。如果编译器需要分配ints、floats和longs的内存的话
发布于 2013-08-12 18:08:34
它可能被定义为(-1)
,因此它是一个隐式的int
。因此,当使用%d
打印时,它正确地显示为-1。但是,当期望一个int
调用未定义的行为时,将long
传递给long
。
可能发生的情况是,您的系统使用了2的补码,32位int
和64位long
,(int)-1
的位模式与(long)4294967295
相同。
https://stackoverflow.com/questions/18193626
复制相似问题