pipe.c
Fri May 10 2024 02:25:59 GMT+0000 (Coordinated Universal Time)
Saved by
@exam123
#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
Comments