Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int wczytywanie(FILE *f);
- int main()
- {
- int size, out, in, temp;
- FILE *we = fopen("in.txt","r");
- char odczyt[101];
- mkfifo("potok",0777);
- out=open("potok",O_WRONLY | O_CREAT | O_TRUNC);
- size = wczytywanie(we)+100;
- temp = 0;
- switch(fork())
- {
- case -1:
- perror("fork error\n");
- exit(1);
- case 0:
- while(temp<=size)
- {
- fgets(odczyt,100,we);
- write(out,odczyt,100);
- printf("Odczyt z pliku, zapis do potoku:\n%s\n",odczyt);
- temp += 100;
- close(out);
- }
- break;
- default:
- printf("Otwarcie potoku do odczytu niemozliwe\n");
- }
- fclose(we);
- return 0;
- }
- int wczytywanie(FILE *f)
- {
- fseek(f,0,SEEK_END);
- int rozmiar = ftell(f);
- rewind(f);
- return rozmiar;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement