您的位置:首页 > 其它

std::string字符串中替换子串的函数

2008-01-23 19:50 357 查看
//std::string中替换子字符串的函数

#include <string>

void string_replace( std::string &strBig, const std::string &strsrc, const std::string &strdst )
{
std::string::size_type pos = 0;
std::string::size_type srclen = strsrc.size();
std::string::size_type dstlen = strdst.size();

while( (pos=strBig.find(strsrc, pos)) != std::string::npos )
{
strBig.replace( pos, srclen, strdst );
pos += dstlen;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐