Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <sys/wait.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <sys/stat.h>
- #include <limits.h>
- #include <inttypes.h>
- int
- main(int argc, char *argv[])
- {
- int fl = open(argv[1], O_RDWR);
- long long num, min = LLONG_MAX;
- int curofst = 0, minofst;
- while (read(fl, &num, sizeof(num)) >= 0) {
- if (num < min) {
- min = num;
- minofst = curofst;
- }
- curofst += sizeof(num);
- }
- if (min == LLONG_MIN) {
- min = 0;
- } else {
- min = -min;
- }
- lseek(fl, SEEK_SET, minofst);
- write(fl, &min, sizeof(min));
- close(fl);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement