C++ std::string 从全路径中提取文件名
C++11
std::string base_name = full_path.substr(full_path.find_last_of("/\\") + 1);
C++17
std::filesystem::path.filename()
例如:
std::filesystem::path("/foo/bar.txt").filename()
C++11
std::string base_name = full_path.substr(full_path.find_last_of("/\\") + 1);
C++17
std::filesystem::path.filename()
例如:
std::filesystem::path("/foo/bar.txt").filename()
评论已关闭