字符“\”替换为“\\”
#include <iostream>
#include <algorithm> //必需加这个头文件
#include <string>
void charReplace(std::string rawStr, std::string &outStr)
{
string::size_type pos = 0;
outStr = rawStr;
while ((pos = outStr.find_first_of('\\', pos)) != string::npos)
{
outStr.insert(pos, "\\");//插入
pos = pos + 2;
}
}