string GetFileExt(string& strFile, int isLower)
{
if(isLower == 1)
{
string strTemp = strFile;
std::transform(strTemp.begin(), strTemp.end(), strTemp.begin(), ::tolower);
string::size_type pos = strTemp.rfind('.');
string strExt = strTemp.substr(pos == std::string::npos ? strTemp.length() : pos+1);
return strExt;
}
else
{
string::size_type pos = strFile.rfind('.');
string strExt = strFile.substr(pos == std::string::npos ? strFile.length() : pos+1);
return strExt;
}
}
从std::string中获取文件路径扩展名
最新推荐文章于 2024-07-03 10:39:10 发布
本文介绍了一种使用C++标准库函数获取文件扩展名的方法,包括处理大小写敏感的情况。通过查找最后一个点号并截取之后的部分来实现。

380

被折叠的 条评论
为什么被折叠?



