关注小韩 轻松编程 一起由浅入深
#include<iostream>
using namespace std;
#include<string> //包含头文件
void test()
{
string str1="hello";
cout << "str1" << endl;
str1.insert(1,"111"); //从第一个位置开始 插入字符串111
cout << "str1=" << str1 << endl;
str1.erase(1, 3); //从第一个位置开始 擦除三个字符
cout << "str1=" <<str1<< endl;
}
int main()
{
test(); //先插入再擦除(阴笑)
return 0;
}
有疑问欢迎评论区留言哦