how to print all files in working directory in c++ code example
Example: get files in directory c++
#include <dirent.h>
std::vector<std::string> GetRecords()
{
std::vector<std::string> files;
struct dirent *entry;
DIR *dir = opendir(record_dir_path.c_str());
if (dir == NULL)
{
return files;
}
while ((entry = readdir(dir)) != NULL)
{
files.push_back(entry->d_name);
}
closedir(dir);
return files;
}