john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

windows dirlist

/* 2010-05 johnpfeiffer experimenting with directories and files */

#include <stdio.h>
#include <sys\stat.h>
#include <dirent.h>

/* struct stat stbuf; */

int main( int argc, char* argv[] )
{
    DIR* dptr;      /* directory pointer from dirent.h, acts like a FILE pointer */
    struct dirent* direntptr; /* C defined struct containing OS file information */

    dptr = NULL;


    dptr =  opendir("\\");
    if( dptr == NULL ) 
    {   printf("error");
    }
    else
    {
        /* currently an endless loop because c:\* is returned!, FIX IT! */
        while( dptr != NULL )
        {            
            printf("%s", dptr->dd_name );   /* dd_name from mingw port, original = name */
            direntptr = readdir( dptr );            
        }

    }

   closedir( dptr );

    return 0;
}

  • « gc bat
  • win wchar from char mbstowcs string to windows »

Published

May 16, 2010

Category

c

~80 words

Tags

  • c 95
  • dirlist 2
  • windows 72