64,637
社区成员
发帖
与我相关
我的任务
分享
string replace_string(string &strSrc, const string &strOld, const string &strNew)
{
string::size_type pos(0);
while (pos = strSrc.find(strOld , pos) != string::npos)
{
strSrc.replace(pos, strOld.length(), strNew);
pos += strNew.length();
cout << pos << '\t' << strSrc << endl;
}
return strSrc;
}
int main(void)
{
string strTest("2001,1,1,23,12,3,1,33,12,");
string strOut = replace_string(strTest, ",", "|");
cout << strOut << endl;
system("pause");
return 0;
}