I am iterating through all the files in a folder and just want their names in a string. I want to get a string from a std::filesystem::path
. How do I do that?
My code:
#include <string>
#include <iostream>
#include <filesystem>
namespace fs = std::experimental::filesystem;
int main()
{
std::string path = "C:/Users/user1/Desktop";
for (auto & p : fs::directory_iterator(path))
std::string fileName = p.path;
}
However I get the following error:
non-standard syntax; use '&' to create a pointer to a member.