回复 10楼 wmf2014
感谢w版

程序代码:#include <cstdio>
#include <string>
#include <clocale>
int wmain()
{
_wsetlocale(LC_ALL, L"chs");
std::wstring str(L"wengbin是个大笨蛋?Tony是个聪明人?");
const std::wstring s1(L"是个");//T版,我现在只看到一个问题,那就是让s1为空(什么也没有),const std::wstring s1(L"");
//这样时,就不能继续下去了,应该要返回原字符串才对,其他还有什么问题嘛?我找不到了呀
const std::wstring s2(L"是不是");
std::wstring::size_type pos = 0;
while ((pos = str.find(s1, pos)) != str.npos)
{
str.replace(pos, s1.size(), s2);
}
wprintf_s(L"字符串: %s\n", str.c_str());
getwchar();
return EXIT_SUCCESS;
}[此贴子已经被作者于2016-1-15 22:38编辑过]
