#include #include #include #include #define MSGSIZE 16 char *msg1 = "Hello, World! "; char *msg2 = "How do you do?"; char *msg3 = "I am a stream"; main() { char inbuf[MSGSIZE]; int p[2]; // pipe descriptor int j; if (pipe(p) < 0) { perror("Pipe call"); return(1); } /* Assert: p[1] to write to, p[0] is to read from */ write(p[1],msg1,MSGSIZE); write(p[1],msg2,MSGSIZE); write(p[1],msg3,MSGSIZE); for (j = 0; j < 3; j++) { read(p[0],inbuf, MSGSIZE); printf("%s\n", inbuf); } return 0; }