请问有人能解释一下这段代码是如何工作的吗?
打印:
我的具体问题是,为什么
另外,有时它会打印:
为什么会出现这个输出?
int main()
{
printf("Hello");
fork();
printf("World");
}
打印:
HelloWorldHelloWorld
我的具体问题是,为什么
hello
会被打印两次。难道不是首先打印hello
,然后执行fork()
吗?另外,有时它会打印:
HelloWorld
// then the reports....process exited with return value 0..etc etc.. then...//
HelloWorld
为什么会出现这个输出?
fork
之前使用fflush
。 - Potatoswatter