hello everybody. i'm trying to use C++17 filesystem library to open all files in a directory.
1 2 3 4 5 6 7 8 9 10
|
#include <iostream>
#include <string>
#include <filesystem>
int main(){
for (auto &f : std::filesystem::directory_iterator("Test")){
std::cout << f;
std::string s = f.string();
}
return 0;
}
|
for some reason, the first line inside the loop works, and the paths are printed. but the second one give me this error:
error: ‘const class std::filesystem::__cxx11::directory_entry’ has no member named ‘string’ |
i'm using:
Debian testing (buster) 64
Code::Blocks 16.01
g++ 8.1.0
and these options to compile: -std=c++17 stdc++fs
Last edited on
oops, i understand now.
i didn't realize the string method was inside the path class. thanks everyone for the help!