c++ get files in directory

#include <iostream>
#include <filesystem>

int main() {
    std::filesystem::path directory_path = "path/to/directory"; // Specify the path to the directory
    for (const auto& entry : std::filesystem::directory_iterator(directory_path)) {
        if (std::filesystem::is_regular_file(entry.path())) {
            std::cout << entry.path().filename() << std::endl; // Output the filename of each regular file
        }
    }
    return 0;
}