Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #################nume.c##################################
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/wait.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <errno.h>
- int main(void)
- {
- int f_in,f_out;
- mkfifo("NameToNumber",0600);
- mkfifo("NumberToName",0600);
- f_in=open("NameToNumber",O_WRONLY);
- f_out=open("NumberToName",O_RDONLY);
- char ch='1';
- char ch1;
- int nume=open("nume.txt",O_RDONLY);
- while(ch!='\n')
- {
- read(nume,&ch,1);
- if(ch!='\n')printf("%c",ch);
- fflush(stdout);
- }
- printf(" ");
- fflush(stdout);
- write(f_in,&ch,1);
- while(read(nume,&ch,1))
- {
- read(f_out,&ch1,1);
- while(ch!='\n')
- {
- printf("%c",ch);
- fflush(stdout);
- read(nume,&ch,1);
- }
- printf(" ");
- fflush(stdout);
- write(f_in,&ch1,1);
- }
- close(f_in);
- close(f_out);
- return 0;
- }
- ##########################telefon.c#####################################################
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/wait.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <errno.h>
- int main(void)
- {
- int f_in,f_out;
- mkfifo("NameToNumber",0600);
- mkfifo("NumberToName",0600);
- f_in=open("NameToNumber",O_RDONLY);
- f_out=open("NumberToName",O_WRONLY);
- char ch='1';
- char ch1;
- int telefon=open("telefon.txt",O_RDONLY);
- while(read(telefon,&ch,1))
- {
- read(f_in,&ch1,1);
- while(ch!='\n')
- {
- printf("%c",ch);
- fflush(stdout);
- read(telefon,&ch,1);
- }
- printf("\n");
- fflush(stdout);
- write(f_out,&ch1,1);
- }
- close(f_in);
- close(f_out);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement