#include <stdio.h>#include <sys/stat.h>#include <sys/types.h>#include <dirent.h>#include <fcntl.h>#include <unistd.h>int main(){ DIR* dir; struct dirent* ent; struct stat file_info; int fd; dir = opendir("."); while ((ent = readdir(dir)) != NULL) { fd = open(ent->d_name, O_RDONLY); fstat(fd, &file_info); if (S_ISREG(file_info.st_mode)) printf("%s\n", ent->d_name); close(fd); } closedir(dir); return 0;}