将C++路径转换成文件名称可以使用std::filesystem::path类中的filename()函数:

#include <filesystem>

std::filesystem::path path("/usr/local/bin/myfile.txt");
std::string filename = path.filename(); // filename = "myfile.txt"
最后修改:2023 年 02 月 20 日
如果觉得我的文章对你有用,请随意赞赏