0

I'm confused because because in this code. I'm not sure that after fork new process moves to beginning because it should not, there should be only one do. The rule is that new process begins after fork instruction, not from the beginning but there is something wrong.

#include<stdio.h>

int main(){
    printf(" do ");
    if(fork()!=0) printf("ma ");
    if(fork()==0) printf("to \n");
    else printf("\n");
}

result

do ma 
do ma to
do to
do

what I think it should be do ma to

melpomene
  • 84,125
  • 8
  • 85
  • 148
nnnn
  • 23
  • 1
  • 5

0 Answers0