0

The problem is that, I have read that the child process will start execution after the fork() system call but then here I must get "This is for sure Parent" only once if the child starts from fork() but as the output shows, it's printing twice.

#include  <stdio.h> 

int main(void)
{
  printf("This is for sure parent\n");
  fork();
  printf("This maybe child or parent\n");
  return 0;
}

Here is the Output:

This is for sure parent
This maybe child or parent
This is for sure parent
This maybe child or parent
Jack
  • 131,802
  • 30
  • 241
  • 343
Haroon khan
  • 1,018
  • 2
  • 15
  • 27

0 Answers0