#include <stdio.h>
#include <unistd.h>
int main()
{
while(1)
{
fprintf(stdout,"hello-out");
fprintf(stderr,"hello-err");
sleep(1);
}
return 0;
}
的上面的输出我的机器上是代码睡在while循环期望输出
hello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-errhello-err
我不得不杀程序停止它。 这是正确和预期的行为。 或者这是错误的。这是一个面试问题,因此我在这里发布。
你问的问题。你的问号键是否被打破。 –
我在那里看到一个问题,它没有问号。但是如果你愿意,你也可以识别它。 – Skurmedel
10K用户可以看到一个相同的问题[这里](http://stackoverflow.com/questions/6283556/buffering-for-stdout-stderr-streams),它由于某种原因被删除。一个耻辱,因为它有很好的答案。 – interjay