c++: list files in folder
This commit is contained in:
parent
4b17968cc9
commit
4f4ec2bc91
17
code/C++/list_files_in_folder.cpp
Normal file
17
code/C++/list_files_in_folder.cpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <set>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
int main(int argc, char const *argv[]) {
|
||||||
|
std::set<std::filesystem::path> sorted_by_name;
|
||||||
|
|
||||||
|
for (const auto &entry : std::filesystem::directory_iterator("/home/user")) {
|
||||||
|
sorted_by_name.insert(entry.path());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &filename : sorted_by_name) {
|
||||||
|
std::cout << filename.c_str() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user