c++ Linux中查找查找文件夹中的所有文件


int find_dir_file(const char *dir_name,vector<string>& v)  //文件夹地址,文件列表
{
    DIR *dirp;
    struct dirent *dp;
    dirp = opendir(dir_name);
    while ((dp = readdir(dirp)) != NULL) {
        v.push_back(std::string(dp->d_name ));
    }
    (void) closedir(dirp);
    return 0;
}

原文地址:https://www.cnblogs.com/orangezs/p/8417156.html