温馨提示×

c++获取当前路径的方法是什么

c++
小亿
112
2023-12-15 11:49:11
栏目: 编程语言

在C++中,可以使用std::filesystem::current_path()函数来获取当前路径。需要包含<filesystem>头文件。

以下是一个示例代码:

#include <iostream>
#include <filesystem>

int main() {
    std::filesystem::path currentPath = std::filesystem::current_path();
    std::cout << "Current Path: " << currentPath << std::endl;
    
    return 0;
}

此代码将输出当前路径。

0