Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <stdint.h>
- struct Item {
- int value;
- uint32_t next_pointer;
- };
- int main(int argc, char *argv[]) {
- int fd = open(argv[1], O_RDONLY);
- if (fd != -1) {
- struct Item cur;
- do{
- if (read(fd, &cur, sizeof(cur)) > 0){
- printf("%d\n",cur.value);
- lseek(fd, cur.next_pointer, SEEK_SET);
- } else {
- close(fd);
- return 0;
- }
- } while(cur.next_pointer != 0);
- close(fd);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment