user4227915
user4227915

Reputation:

How to get the folders in c?

I have a "html" folder and I want to know the folders inside it.

This code is only to demonstrate what I'm trying:


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

int main( void)
{
    FILE *fp;

    printf("Folders inside html-folder:\n");

    /* for ( fp in ("html\\*") ) { */

        /* if ( fp is folder ) */
            printf("%s-folder \n", folderName);

    /* } */

    return 0;
}

I think there must have a function to do this in an easy way, but I don't know any.

Any help is welcome!

Upvotes: 0

Views: 50

Answers (1)

abelenky
abelenky

Reputation: 64682

You want the functions FindFirstFile and FindNextFile.
I think the documentation on both functions is very clear.
Do you have a specific question about them?

Upvotes: 1

Related Questions