Definition of wikipedia says that
"The fork operation creates a separate address space for the child. The child process has an exact copy of all the memory segments of the parent process, though if copy-on-write semantics are implemented actual physical memory may not be assigned (i.e., both processes may share the same physical memory segments for a while). Both the parent and child processes possess the same code segments, but execute independently of each other."
And also in Let us C book, by Yashvant kanetkar it is mentioned as
"Fork doesn't mean that the child process contains the data and code below the fork() call."
Then why does this code prints only the statements below the fork twice compared to printing all the statements twice.
Code:
#include<stdio.h>
#include<sys/types.h>
int main()
{
printf("Before forking\n");
fork();
printf("After forking\n");
}



.
