代码之前(1)不运行

Dan*_*cal -2 c ansi-c

我的代码如下:

#include <stdio.h>

int main(int argc, char *argv[]) {
    printf("hello");

    while(1){
        // whatever here
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是:为什么跳过第一条指令?它只运行循环,你永远不会打印.我使用gcc和g ++编译它,结果相同.

Bat*_*eba 5

确实运行,只是输出缓冲区在你的之前没有被刷新while.

printf("hello\n");改用.换行符将刷新缓冲区,以便立即将输出写入控制台.