c++filesystem中path转string
时间: 2023-06-21 20:17:56 浏览: 349
C++,图片显示,数组
可以使用`c++`标准库`std::filesystem`中的`std::filesystem::path::string()`函数,将`path`对象转化为`string`类型。示例如下:
```cpp
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main() {
fs::path p = "example.txt";
std::string str = p.string();
std::cout << "Path: " << p << std::endl;
std::cout << "String: " << str << std::endl;
return 0;
}
```
输出结果为:
```
Path: "example.txt"
String: "example.txt"
```
阅读全文