string 的 replace()函数写法

来源:互联网 发布:投诉淘宝卖家有啥后果 编辑:程序博客网 时间:2024/05/16 00:57

string& replace_all ( string& str , const string oldword, const string newword )

{

while(true )

{

string::size_type pos(0);

if( ( pos = str.find(oldword) ) != string::npos )

{

str.replace( pos, oldword.length(), newword );

}

else

{

break;

}

}

return str;

}

原创粉丝点击