Recursive version of LS in c programming

[ad_1]

Recursive version of LS in c programming
#include 
#include 
#include 
#include 
#include 

void listdir(const char *name, int indent)
{
    DIR *dir;
    struct dirent *entry;

    if (!(dir = opendir(name)))
        return;

    while ((entry = readdir(dir)) != NULL) {
        if (entry->d_type == DT_DIR) {
            char path[1024];
            if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
                continue;
            snprintf(path, sizeof(path), 
            printf(
            listdir(path, indent + 2);
        } else {
            printf(
        }
    }
    closedir(dir);
}

int main(void) {
    listdir(".", 0);
    return 0;
}

[ad_2]

Please follow and like us:
Content Protection by DMCA.com