C++ 获取文件夹下所有文件名

    xiaoxiao2022-06-30  99

    C++ 获取文件夹下所有文件名

    使用c++17对文件系统的官方支持

    #include <filesystem> #include <iostream> namespace fs = std::filesystem; int main(){ string path = "./imgs"; for (const auto &entry : fs::directory_iterator(path)){ std::cout << entry.path() << std::endl; } }

    使用g++直接编译可能错误,需要加上

    g++ dehaze.cpp -std=c++17 -lstdc++fs

    参考自stackoverflow


    最新回复(0)