c++字符串批量替换

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_31339221/article/details/78230673
void Replace()
{
	offindex = s1.find("wbm",0);
	while( offindex != string::npos )
	{
		cout<<"offindex:"<<offindex<<endl;
		s1.replace(offindex,3,"WBM");
		offindex +=1;
		offindex = s1.find("wbm",offindex);
	}
	cout<<s1<<endl;
}

猜你喜欢

转载自blog.csdn.net/qq_31339221/article/details/78230673