readdir.c 481 B

12345678910111213141516171819202122
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* a simple helloworld test */
  4. #include <stdio.h>
  5. #include <dirent.h>
  6. #include <fcntl.h>
  7. int main(int argc, char ** argv)
  8. {
  9. struct dirent * dirent;
  10. DIR * dir = opendir(".");
  11. while ((dirent = readdir(dir)))
  12. printf("found %s\n", dirent->d_name);
  13. closedir(dir);
  14. return 0;
  15. }