1. 程式人生 > >獲取Windows某一目錄下的所有文件名

獲取Windows某一目錄下的所有文件名

edi printf windows push_back ex18 while plain processor vector

#include <sys/types.h> #include <dirent.h> std::vector<std::string> get_all_filename(char* dirname) { DIR *dp; struct dirent* dirp; std::vector<std::string> filename_vector; if((dp = opendir(dirname)) == NULL) { printf("this dir maybe not exist"
); } while((dirp = readdir(dp)) != NULL) { filename_vector.push_back(dirp->d_name); } closedir(dp); return filename_vector; }

獲取Windows某一目錄下的所有文件名