#include <iostream>
#include <cstring>
void stringReplace(std::string& strOri, const std::string& strsrc, const std::string& strdst){
std::string::size_type pos = 0;
std::string::size_type srclen = strsrc.size();
std::string::size_type dstlen = strdst.size();
while ((pos = strOri.find(strsrc, pos)) != std::string::npos){
strOri.replace(pos, srclen, strdst);
pos += dstlen;
}
}
std::string getPathShortName(std::string strFullName){
if (strFullName.empty()){
return "";
}
stringReplace(strFullName, "\", "/");
std::string::size_type iPos = strFullName.find_last_of('/') + 1;
return strFullName.substr(iPos, strFullName.length() - iPos);
}
int main(){
std::string tempPath = "E:\test_models\test.obj";
std::string filename = getPathShortName(tempPath);
std::cout << "filename: " << filename << std::endl;
}