int main ()
{
printf ("Hello World!");
if (fork == 0)
    printf ("I'm the child!\n");
else
    printf ("I'm the parent!\n");
}

The output of the above program is :

Hello World!I'm the child!
Hello World!I'm the parent!


Why is "Hello World" being printed twice?
Only the parent should print it right?

If "Hello World" is appended with a "\n" the output is...

Hello World!I'm the child!
I'm the parent!

Hello World is printed only once.Can anybody please explain whats goin on?
My guess is this because the stdout isnt flushed before the child is created.
Please help.
Thanks a lot.




--
Regards,
Ashutosh Adkar

--
______________________________________________________________________
Pune GNU/Linux Users Group Mailing List:      (plug-mail@plug.org.in)
List Information:  http://plug.org.in/cgi-bin/mailman/listinfo/plug-mail
Send 'help' to [EMAIL PROTECTED] for mailing instructions.

Reply via email to