Why the printf() that precede the fork() gets executed even after the fork()? [duplicate] Why the printf() that precede the fork() gets executed even after the fork()? [duplicate] unix unix

Why the printf() that precede the fork() gets executed even after the fork()? [duplicate]


Because you didn't flush the output buffer and so the text exists in both parent and child's output buffer after the fork().

Add fflush(stdout); after the first printf() and see the difference.