#include #include using namespace std; int main(){ int pipefd[2]; // 0 = reading end, 1 = writing end char cbuf[20]; char pbuf[20]; pipe(pipefd); int a = fork(); if(a == 0){ cout << "reading end = " << pipefd[0] << endl; read(pipefd[0], cbuf, sizeof(cbuf)); cout << "Child: " << cbuf << endl; write(pipefd[1], "And I am the child" , 18); } else { cout << "writing end = " << pipefd[1] << endl; write(pipefd[1], "I am your parent", 16); read(pipefd[0], pbuf, sizeof(pbuf)); cout << "Parent: " << pbuf << endl; } }