I am trying to understand the fork() concept and there's is one thing I can't seem to understand.
In the following code - why does the parent still print i=0 even when child process changes it to 5?
The wait(NULL) blocks parent process until child finishes first.
int main(int argc, char *argv[]) {
  int i = 0;
  if (fork() == 0) {
    i = 5;
  } else {
    wait(NULL);
    printf("i = %d\n", i);
  }
  return 0;
}
Can somebody explain why my assumption is incorrect?
 
     
     
     
    