Can anyone, please, explain how does this code work ?
int main()
{
printf("Hello");
fork();
printf("World");
}
Prints:
HelloWorldHelloWorld
My exact question is, why hello
is printed twice. Isn't hello
printed first, then fork()
is executed ?
Also, sometimes it prints:
HelloWorld
// then the reports....process exited with return value 0..etc etc.. then...//
HelloWorld
Why this output ?