Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <fcntl.h>
  4. #include <unistd.h>
  5. int main(){
  6. char buf[512];
  7. int p, p2, lbajt;
  8.  
  9. p=open("/tmp/erykzjeb", O_RDONLY);
  10. if ( p == -1){
  11. perror("Blad otwarcia pliku zrodlowego");
  12. exit(1);
  13. }
  14.  
  15. p2=open("/tmp/zuza", O_WRONLY);
  16. if ( p2 == -1){
  17. perror("Blad otwarcia pliku zrodlowego");
  18. exit(1);
  19. }
  20.  
  21. while((lbajt = read(p, buf, 512)) > 0){
  22. if (write(p2, buf, lbajt) == -1){
  23. perror("Blad zapisu pliku docelowego");
  24. exit(1);
  25. }
  26. write(1,buf,lbajt);
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement