readdir.c 278 B

1234567891011121314151617
  1. #include <dirent.h>
  2. #include <fcntl.h>
  3. #include <stdio.h>
  4. int main(int argc, char** argv) {
  5. struct dirent* dirent;
  6. DIR* dir = opendir(".");
  7. while ((dirent = readdir(dir))) {
  8. printf("found %s\n", dirent->d_name);
  9. }
  10. closedir(dir);
  11. return 0;
  12. }