Write a c program for message passing using pipes. - Code

Latest

programs

Thursday, October 6, 2011

Write a c program for message passing using pipes.


Write a c program for message passing using pipes.


#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main()
{
int fd[2];
if(pipe(fd)<0)
exit(1);
if(fork())
{
close(fd[0]);
write(fd[1], “Message from Suhrit”12);
}
else
{
char buf[100];
close(fd[1]);
read(fd[0],buf,100);
printf(“Received by Students of SuhritSolutions:%s\n”,buf);
fflush(stdout);
}
exit(0);
}

No comments:

Post a Comment