#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
void test01()
{
string str = "Hello";
//插入 输出结果:H520llo
str.insert(1, "520");
cout << "str = " << str << endl;
//删除 参数1 起始位置, 参数2 删除字符的个数
str.erase(1, 3);
cout << "str = " << str << endl;
}
int main()
{
test01();
system("pause");
return 0;
}
(5)string-字符串插入和删除
最新推荐文章于 2024-01-10 17:51:46 发布