im new to programming c in unix
this is program written by me i want each and every child to do a seperate work such implement a different sorting algorithm but im not getting the way i wrote as below...plz help me how can i do that
#include<stdio.h>
main()
{
int i;
for(i=0;i<5;i++)
{
fork();
child(i);
exit(0);
}
}
child(int j)
{
switch(j)
{
case 0: printf("iam child1 %d\n",j);
break;
case 1: printf("iam child 2 %d\n",j);
break;
default: printf("iam other\n");
}
return;
}
i want child 1 to execute case 1 child 2 to execute case 2....but all childs are executing only case 0
thank u