为什么以下程序不会生成任何可见输出?

Bin*_*inu 0 c printf

以下C程序不会在屏幕上打印任何内容.

我编译了程序gcc:

#include<stdio.h>

main()
{
    printf("hai");
    for(;;);
}
Run Code Online (Sandbox Code Playgroud)

Sin*_*nür 9

最有可能的stdout是行缓冲.您的程序不会调用fflush或发送换行符,因此缓冲区不会被写出来.

#include <stdio.h>

int main(void) {
    printf("hai\n");
    for(;;)
    ;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

另见问题12.4以及main()的正确声明是什么?C FAQ中.