Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. // #include <fcntl.h>
  3.  
  4. int main(int argc, char* argv[]){
  5. int fin = creat("a.txt",O_RDONLY);
  6. int fout = creat("b.txt",O_WRONLY);
  7. int current = 0;
  8. int total = lseek(fin,0,SEEK_END)
  9. lseek(fin,0,SEEK_SET)
  10. char tab[20];
  11. int a = 0;
  12. char c;
  13. int i = 0;
  14. int h1 = 1;
  15. int h = 1;
  16. while(current < total){
  17. i = 0;
  18. h1 = 1;
  19. while(h1 && a != -1){
  20. a = read(fin,&c,1);
  21. if(c != '\n' && a!=-1){
  22. tab[i] = c;
  23. h1 = 1;
  24. }
  25. else{
  26. h1 = 0;
  27. }
  28. i++;
  29. }
  30. current = current + i;
  31. while(i>0){
  32. write(fout, tab[i], 1);
  33. i--;
  34. }
  35. write(fout, '\n', 1);
  36. }
  37. close(fin);
  38. close(fout);
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement