Question: can someone to expalin me this code ? #include #include #include #include #include int main ( ) { FILE * filename = fopen (

can someone to expalin me this code ? #include
#include
#include
#include
#include
int main(){
FILE *filename = fopen ("writeToFile.dat", "w");
if (fork ()==0){
for (int i =0; i <3; i++){
printf ("First child P1
");
fprintf (f, "First child P1
");
}
}
else if (fork ()==0){
for (int i =0; i <2; i++){
printf ("Second child P2
");
fprintf (f, "Second child P2
");
}
}
else if (fork ()==0){
printf ("Third child P3
");
fprintf (f, "Third child P3
");
}
else {// Parent
wait (NULL); // wait for one child to finish
wait (NULL); // wait for another child to finish
wait (NULL); // wait for last child to finish
fclose (f);
}
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!