I'm writing a program where I need to print all the files in a given folder and store the content of the files in order to compare it to another string. What I have now is:
while ((ent = readdir(dir)) != NULL)
        {
            if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, ".."))
            {
                // do nothing (straight logic)
            }
            else {
                file_name = ent->d_name;
                printf("%s\n", file_name);
                file_name = ent->d_name;
            printf("%s\n", file_name);
            char *fd = file_name;
            struct stat *buf;
            buf = malloc(sizeof(struct stat));
            stat(fd, buf);
            int size = buf->st_size;
            printf("%d", size);
            }
        }
edit: my problem now is that it prints the size as negative