Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdint.h>
- struct Data
- {
- int16_t x;
- int64_t y;
- };
- int
- main (int argc,char **argv)
- {
- enum { MAX_BUF = 10 };
- int buf1[MAX_BUF], buf2[MAX_BUF];
- int f, count = 0, i = 1;
- struct Data *str;
- f = open(argv[1],O_RDWR)
- while(read(f, &str.x, 2) != 0 && read(f, &str.y, 8) != 0) {
- str.y += str.x * argv[2];
- ++count;
- }
- lseek(f, count*MAX_BUF, 2);
- while(i <= count/2) {
- read(f, buf1, MAX_BUF);
- lseek(f, i*MAX_BUF, 2);
- read(f, buf2, MAX_BUF);
- lseek(f, i*MAX_BUF, 2);
- write(f, buf1, MAX_BUF);
- lseek(f, i*MAX_BUF, 0);
- write(f, buf2, MAX_BUF);
- ++i;
- }
- close(f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement