【发布时间】:2014-09-28 07:22:04
【问题描述】:
谁能解释一下这段代码是如何工作的?
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
为什么会有这个输出?
【问题讨论】: