Guest User

Untitled

a guest
Nov 15th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include<sys/stat.h>
  2. #include<fcntl.h>
  3. #include<unistd.h>
  4.  
  5. int copy(int old, int new)
  6. {
  7. int count;
  8. char buffer[10];
  9. while((count=read(old,buffer,sizeof(buffer)))>0)
  10. {
  11. write(new,buffer,count);
  12. }
  13. close(old);
  14. close(new);
  15. }
  16.  
  17. int main(int argc, char *argv[])
  18. {
  19. int fold,fnew;
  20. fold=open(argv[1],O_RDONLY);
  21. fnew=creat(argv[2],0777);
  22. copy(fold,fnew);
  23. return 0;
  24. }
Add Comment
Please, Sign In to add comment