<pre name="code" class="cpp">#include <iostream>
#include <algorithm> //必需加这个头文件
#include <string>
using namespace std;
int main()
{
string::size_type pos=0;
string test="fsffsfd\\fdsfsfd\\fdsfsd";
cout<<test<<endl;
while((pos=test.find_first_of('\\',pos))!=string::npos)
{
test.insert(pos,"\\");//插入
pos=pos+2;
}
cout<<test<<endl;
return 0;
}
C++ 把文件路径中的单斜杠“\”换成双斜杠“\\”
最新推荐文章于 2022-07-19 16:25:11 发布