想把"/n"换成"//n"怎么办?因为std::string并未实现替换所有子串功能,故封装一个函数
void StringReplace(string &strBase, string strSrc, string strDes)
{
string::size_type pos = 0;
string::size_type srcLen = strSrc.size();
string::size_type desLen = strDes.size();
pos=strBase.find(strSrc, pos);
while ((pos != string::npos))
{
strBase.replace(pos, srcLen, strDes);
pos=strBase.find(strSrc, (pos+desLen));
}
}

7537

被折叠的 条评论
为什么被折叠?



