#include<stdio.h>
#include <unistd.h>
int main(){
while(1)
{
fprintf(stdout,"hello-out");
fprintf(stderr,"hello-err");
sleep(1);
}
return 0;
}
在gcc中編譯這個程序並執行它時,只打印出hello-err而不是hello-out。爲什麼會這樣?有人可以解釋它背後的原因嗎?爲什麼這個c程序不打印第一個printf語句?
你的平臺是什麼? –
你在哪裏看過你的印刷文字?首先'printf'打印到'stdout',然後打印到'stderr'。在你的情況下,可能是不同的輸出流 – Nekto
@ JimBuck - 我正在使用Fedora Linux。 – bornfree