#include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<sys/types.h> #include<fcntl.h> #include<string.h> int main(){ char string[]="welcome"; char b[80]; int fd[2],x; pid_t pid; pipe(fd); pid=fork(); if(pid==0){ close(fd[0]); write(fd[1],string,strlen(string)+1); }else{ close(fd[1]); x=read(fd[0],b,sizeof(b)); printf("received string is %s",b); } return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter