#include #include #include #include #include #include #include void piped(){ int fd[2]; if(pipe(fd) == -1){ printf("an error occured\n"); return ; } pid_t pid = fork(); if(pid < 0){ printf("an error occured\n"); return ; } // Child if (pid == 0) { close(fd[0]); char *str = "Hello from your child !\n"; write(fd[1], str, strlen(str) + 1); close(fd[1]); exit(0); } // Mommy else { close(fd[1]); char buffer[2048]; read(fd[0], buffer, sizeof(buffer)); printf("My child sends me : %s", buffer); close(fd[0]); wait(NULL); return; } } //int main(){ piped();}