代码:
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
int main()
{
string s = "abc123def";
s.replace(
s.find("123"), // 被替换的位置
3, // 被替换的大小
"" // 用来取代该位置的字符串
);
cout << s << endl;
return 0;
}
效果图: