Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- int
- main(int argc, char *argv[])
- {
- int fd = open(argv[1], O_RDWR);
- off_t min_ind = -1;
- long long min, tmp;
- for (off_t cnt = 0; read(fd, &tmp, sizeof(tmp)) == sizeof(tmp); cnt += sizeof(tmp)) {
- if (min_ind == -1 || tmp < min) {
- min = tmp;
- min_ind = cnt;
- }
- }
- lseek(fd, min_ind, SEEK_SET);
- min = -min;
- if (write(fd, &min, sizeof(min)) < sizeof(min)) {
- return 1;
- }
- close(fd);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement