how to find folders from a c program

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

int main() {
    struct dirent *entry;
    DIR *dp = opendir("/path/to/your/directory");

    if (dp == NULL) {
        perror("opendir");
        return 1;
    }

    while ((entry = readdir(dp))) {
        if (entry->d_type == DT_DIR) {
            printf("%s\n", entry->d_name);
        }
    }

    closedir(dp);
    return 0;
}