以下 C 程序不会在屏幕上打印任何内容。
我用gcc
编译程序:
#include<stdio.h>
main()
{
printf("hai");
for(;;);
}
最佳答案
很可能,stdout
是行缓冲的。你的程序不调用 fflush
或发送一个换行符,这样缓冲区就不会被写出。
#include <stdio.h>
int main(void) {
printf("hai\n");
for(;;)
;
return 0;
}
另见 question 12.4和 What's the correct declaration of main()?在C FAQ .
关于c - 为什么下面的程序没有生成任何可见的输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1260213/