Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. int wczytywanie(FILE *f);
  2.  
  3. int main()
  4. {
  5. int size, out, in, temp;
  6. FILE *we = fopen("in.txt","r");
  7. char odczyt[101];
  8. mkfifo("potok",0777);
  9. out=open("potok",O_WRONLY | O_CREAT | O_TRUNC);
  10. size = wczytywanie(we)+100;
  11. temp = 0;
  12. switch(fork())
  13. {
  14. case -1:
  15. perror("fork error\n");
  16. exit(1);
  17. case 0:
  18. while(temp<=size)
  19. {
  20. fgets(odczyt,100,we);
  21. write(out,odczyt,100);
  22. printf("Odczyt z pliku, zapis do potoku:\n%s\n",odczyt);
  23. temp += 100;
  24. close(out);
  25. }
  26. break;
  27. default:
  28. printf("Otwarcie potoku do odczytu niemozliwe\n");
  29. }
  30. fclose(we);
  31. return 0;
  32. }
  33.  
  34.  
  35. int wczytywanie(FILE *f)
  36. {
  37. fseek(f,0,SEEK_END);
  38. int rozmiar = ftell(f);
  39. rewind(f);
  40. return rozmiar;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement