while I am trying to code in c for zombie process simulation ,I am getting alteration in output due to putting of \n in printf statements:
code1:
main()
{
int id;
id=fork();
if(id>0)
{
printf("Parent will sleep");//pf1//
sleep(5);
//system("ps -u");
}
if(id==0)
printf("I am child");//pf2//
}
output:
I am childParent will sleep
but while putting \n in pf1 or pf2 the order of execution of statements changes.what is the reason behind \n altering the order ?
Aucun commentaire:
Enregistrer un commentaire