home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / MASTER-1.ZIP / SOURCE / CHAP06 / CHAP06.LZH / OPENDIR.CPP < prev    next >
C/C++ Source or Header  |  1992-07-02  |  481b  |  23 lines

  1. /* OPENDIR.C
  2.    Demonstrates use of the opendir(), readdir() and
  3.    closedir() functions.
  4. */
  5. #include <stdio.h>
  6. #include <dirent.h>
  7. void main(void)
  8. {
  9.   DIR * pDirectory;
  10.   struct dirent * pEntry;
  11.  
  12.   pDirectory = opendir("C:\\SBM");
  13.   if (pDirectory == NULL)
  14.     puts("Unable to open the directory.\n");
  15.   else do {
  16.      pEntry = readdir( pDirectory );
  17.      if (pEntry != NULL) puts( pEntry->d_name );
  18.   } while (pEntry != NULL);
  19.  
  20.   closedir( pDirectory );
  21. }
  22.  
  23.