Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdint.h>
  4.  
  5. struct Data
  6. {
  7.     int16_t x;
  8.     int64_t y;
  9. };
  10.  
  11. int
  12. main (int argc,char **argv)
  13. {
  14.     enum { MAX_BUF = 10 };
  15.     int buf1[MAX_BUF], buf2[MAX_BUF];
  16.     int f, count = 0, i = 1;
  17.     struct Data *str;
  18.     f = open(argv[1],O_RDWR)
  19.     while(read(f, &str.x, 2) != 0 && read(f, &str.y, 8) != 0) {
  20.         str.y += str.x * argv[2];
  21.         ++count;
  22.     }
  23.     lseek(f, count*MAX_BUF, 2);
  24.     while(i <= count/2) {
  25.         read(f, buf1, MAX_BUF);
  26.         lseek(f, i*MAX_BUF, 2);
  27.         read(f, buf2, MAX_BUF);
  28.         lseek(f, i*MAX_BUF, 2);
  29.         write(f, buf1, MAX_BUF);
  30.         lseek(f, i*MAX_BUF, 0);
  31.         write(f, buf2, MAX_BUF);
  32.         ++i;
  33.     }
  34.     close(f);
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement