#include<stdio.h>
void main()
{
int i = -1, j = 1,k,l;
k=!i&&j;
l= !i||j;
printf("\n%d\n%d",i,j);
}
在输出中显示:Runtime error time: 0 memory: 10304 signal:-1
但是如果我用 int 替换 void 并在程序中添加 return 0 ,它可以正常工作,没有任何错误,为什么?
最佳答案
C11 标准中没有描述
void main()
。有些实现可以自由地“合法化”它。显然,您使用的实现在这方面遵循了标准。
尝试int main(void)
,即 mandated by the Standard to be correct (C11, 5.1.2.2.1) .
关于c - 输出正确,但在 c 中显示运行时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44868457/