pipe

PHOTO EMBED

Wed May 08 2024 09:26:29 GMT+0000 (Coordinated Universal Time)

Saved by @signup

#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;
     }
content_copyCOPY