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;
}
}
参考:http://blog.sina.com.cn/s/blog_af95b18b01017jpu.html