Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<unistd.h>
- #include<fcntl.h>
- #include<sys/types.h>
- #include<sys/stat.h>
- #include<string.h>
- int main() {
- char file_name[30] = "";
- char file_content[1000] = "";
- mkfifo("fifo1", 0600);
- mkfifo("fifo2", 0600);
- int fd = open("fifo1", O_RDONLY);
- int file1 = open("fifo2", O_WRONLY);
- read(fd, file_name, 30);
- int file2 = open(file_name, O_RDONLY);
- while(read(file2, file_content, 500) != 0) {
- printf("%s\n", file_content);
- if(fd < 0) {
- write(file1, "file does not exist! try again please!", 14);
- return 0;
- }
- else {
- write(file1, file_content, strlen(file_content));
- }
- }
- close(fd);
- close(file1);
- close(file1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement