为啥死循环外的printf没法输出内容呢?
#include <stdio.h>
int main()
{
printf("HELLO WOLRD");
while(1){
}
}
如上面代码所示,程序可以编译并且执行,但是printf就是没有办法输出,把while死循环去掉就可以了
[解决办法]
用fflush(stdin)刷新输入缓冲区,或者输出到stderr:
fprintf(stderr, "HELLO WOLRD");