Listing files of a directory.

Functions to get the list of all files of a directory, getting subdirectories.

_findfirst,_findnext,_chdir

See version :

Pas de dépendances

Download :

#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <direct.h>

void dir()
{
    struct _finddata_t D;
    int done=0;
    int hd;
    hd = _findfirst("*.*",&D);
    if (hd==-1)
        return;
    while (!done) 
    {
        printf("%s\n",D.name);
        done = _findnext(hd,&D);
    }
}

void dirS()
{
    struct _finddata_t D;
    int done=0;
    int hd;
    hd = _findfirst("*.*",&D);
    if (hd==-1)
        return;
    while (!done) 
    {
        if (D.name[0]!='.')
        {
            if (D.attrib&0x10)
            {
                printf("Entree Repertoire %s\n",D.name);
                _chdir(D.name);
                dirS();
                printf("Sortie Repertoire %s\n",D.name);
                _chdir("..");
            }
            else
                printf("%s\n",D.name);
        }
        done = _findnext(hd,&D);
    }
}

int main()
{
    dir();
    //dirS();
    return 0;
}



Explanations

	Please care about these functions.
	No explanations yet.