Terminal1.c
#include<stdio.h>
#include<fcntl.h>
#include<unistd.h>
#include<sys/stat.h>
#include<string.h>
int main(){
int tid;
char string[BUFSIZ];
printf("enter message");
scanf("%s",string);
tid=open("MyPipe",O_WRONLY);
write(tid,string,sizeof(string));
unlink("MyPipe");
close(tid);
return 0;
}
Teminal2.c
#include<stdio.h>
#include<fcntl.h>
#include<unistd.h>
#include<sys/stat.h>
#include<string.h>
int main(){
int tid;
char string[BUFSIZ];
mkfifo("MyPipe",0666);
tid=open("MyPipe",O_RDONLY);
read(tid,string,sizeof(string));
printf("%s",string);
unlink("MyPipe");
close(tid);
return 0;
}
Post a Comment