#include
#include
#include
#include
#include
void main()
{ char buffer[10][5];pid_t childpid;
int pd[2],n,st,i=0,k=0;
printf("\n enter the no of strings(<=10)");
scanf("%d",&n);
st=pipe(pd);
if(st==-1)
{ printf("\n unable to create pipes");
exit(0);
}
childpid=fork();
if (childpid==0)
{ //child
printf("\n child process prints string\n ");
// char demo[10][5];
close(pd[1]);
read(pd[0],buffer,sizeof(buffer));
for(i=0;i
}
}
else
{//parent
printf("\n parent process takes and sends string");
close(pd[0]);
k=0;
while(k
printf("\nenter string %d ",k+1);
scanf("%s",buffer[k]);
k++;
}
write(pd[1],buffer,sizeof(buffer));
waitpid(childpid,NULL,0);
}
}//end of main
#include"stdio.h"
ReplyDelete#include"sys/types.h"
#include"unistd.h"
#include"string.h"
#include"stdlib.h"