pipes
Wed May 08 2024 09:06:34 GMT+0000 (Coordinated Universal Time)
Saved by
@signup
#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;
}
content_copyCOPY
Comments