#include<stdio.h> #include<unistd.h> #include<sys/types.h> #include<string.h> #include<stdlib.h> int main(){ int fd[2],x; pid_t pid; char string[]="welcome"; char b[80]; pipe(fd); pid=fork(); if(pid==0){ close(fd[0]); write(fd[1],string,(strlen(string)+1)); exit(0); } else{ close(fd[1]); x=read(fd[0],b,sizeof(b)); printf("received string:%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