Unix System Calls - opendir readdir


// Unix system calls
// opendir, readdir

#include <stdio.h>
#include <dirent.h>

int main()
{
          struct dirent *de; 

          DIR *dr = opendir(".");

          if (dr == NULL)
          {
                   printf("Could not open current directory" );
                   return 0;
          }

          while ((de = readdir(dr)) != NULL)
                             printf("%s\n", de->d_name);

          closedir(dr);
          return 1;


}

3 comments:

Don't be a silent reader...
Leave your comments...

Anu