#include<iostream>
#include<string>
using namespace std;
int main()
{
string total = "C:\\Users\\jack\\Documents\\Visual Studio 2015\\Projects\\GetScaleImgPart\\x64\\Release";
int pos = total.rfind("\\",total.length());//从后往前寻找第一个/出现的位置
total = total.substr(0, pos);//剪切[0,pos]
cout << pos << total.length() << endl;
cout << total << endl;
getchar();
return 0;
}
C++路径存储在string中,去掉路径中最后一个文件夹的名字
最新推荐文章于 2023-03-19 22:19:58 发布