"C++ 17 获取当前执行程序目录:std::filesystem::current_path() 使用指南"\n\n在 C++17 中,可以使用 std::filesystem::current_path() 函数来获取当前执行程序的目录。这个函数返回一个 std::filesystem::path 对象,表示当前路径。\n\n下面是一个简单的示例代码:\n\ncpp\n#include <iostream>\n#include <filesystem>\n\nint main() {\n std::filesystem::path currentPath = std::filesystem::current_path();\n std::cout << \"Current path: \" << currentPath << std::endl; \n\n return 0; \n}\n\n\n这段代码将输出当前执行程序的目录。请注意,std::filesystem 库是 C++17 中引入的新特性,因此你需要使用支持 C++17 的编译器来编译这段代码。

C++17 获取当前执行程序目录:std::filesystem::current_path() 使用指南

原文地址: https://www.cveoy.top/t/topic/qkbu 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录