Guest User

Untitled

a guest
Jan 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <fcntl.h>
  4.  
  5. int f1,f2,i=-1;
  6. char *c;
  7.  
  8. int main(int argc,char *argv[])
  9. {
  10. f1=open(argv[1],O_RDONLY);
  11. f2=open(argv[2],O_WRONLY);
  12. printf("%d %d\n",f1,f2);
  13.  
  14. if (f1>=0)
  15. {
  16. lseek(f1,i,2);
  17. while (read(f1,&c,1))
  18. {
  19. write(f2,&c,1);
  20. --i;
  21. if (lseek(f1,i,2)==-1)
  22. break;
  23. }
  24. }
  25.  
  26. close(f1);
  27. close(f2);
  28. ulink(argv[1]);
  29. link(argv[2],argv[1]);
  30. ulink(argv[2]);
  31.  
  32. printf("OK\n");
  33. return 0;
  34. }
Add Comment
Please, Sign In to add comment