Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <fcntl.h>
- #include <errno.h>
- int main()
- {
- int f=open("nume.txt",O_RDONLY);
- char ch='y';
- int readcode;
- int p[2],q[2];
- mkfifo("p",0600);
- mkfifo("q",0600);
- q[1]=open("q",O_WRONLY);
- p[0]=open("p",O_RDONLY);
- while(1)
- {
- read(p[0],&ch,1);
- while(1)
- {
- readcode=read(f,&ch,1);
- if(readcode==0)
- break;
- if(ch=='\n')
- break;
- printf("%c",ch);
- }
- printf(" ");
- if(readcode==0)
- break;
- write(q[1],&ch,1);
- }
- close(p[0]);
- close(q[1]);
- }
- /////////////////////////////////////////////////////
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <fcntl.h>
- #include <errno.h>
- int main()
- {
- int f=open("telefon.txt",O_RDONLY);
- char ch='x';
- int p[2],q[2],readcode;
- mkfifo("p",0600);
- mkfifo("q",0600);
- q[0]=open("q",O_RDONLY);
- p[1]=open("p",O_WRONLY);
- write(p[1],&ch,1);
- while(1)
- {
- read(q[0],&ch,1);
- while(1)
- {
- readcode=read(f,&ch,1);
- if(readcode==0)
- break;
- if(ch=='\n')
- break;
- printf("%c",ch);
- }
- printf("\n");
- if(readcode==0)
- break;
- write(p[1],&ch,1);
- }
- close(p[1]);
- close(q[0]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement