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

static int get_files()
{
    DIR *dirp;
    struct dirent *dp;

    dirp = opendir(".");
    if (dirp == NULL) {
        return -1;
    }

    while ((dp = readdir(dirp)) != NULL) {
        printf("%s\n", dp->d_name);
    }

    (void) closedir(dirp);
    return 0;
}

int main(int argc, char const *argv[])
{
    get_files();

    return 0;
}
Logo

更多推荐