扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

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

扬州沐宇科技
2023-12-15 11:49:11
c++

在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;
}

此代码将输出当前路径。

扫码添加客服微信