Advertisement
obernardovieira

Find folder and files in directory (for windows, unix style)

Jul 30th, 2013
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include "dirent.h"
  2. #include <iostream>
  3.  
  4. bool main() {
  5.     DIR *dir;
  6.     struct dirent *ent;
  7.     if ((dir = opendir ("c:\\")) != NULL) {
  8.         /* print all the files and directories within directory */
  9.         while ((ent = readdir (dir)) != NULL) {
  10.             printf ("%s\n", ent->d_name);
  11.         }
  12.         closedir (dir);
  13.     } else {
  14.         /* could not open directory */
  15.         perror ("");
  16.         return EXIT_FAILURE;
  17.     }
  18.     system("pause");
  19.     return true;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement