0

why in this example when I used '\n' in the first printf() I got just one "Hi" but when I remove it I got two, one of the parent process and the other of kid process.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main()
{
  printf ("Hi\n");
  int pid=fork();
 // if (fork())
  if (pid!=0)
    printf (" I'm the parent\n");
  else
    printf (" I'm the kid\n");
}

for anyone try to explain this situation thank you.

0 Answers0