#include<iostream>
#include<string>
using namespace std;
//string字符插入和删除
void test1() {
string str;
str = "hello";
cout << str << endl;
//插入
//从第一个位置插入"111" 完成后为h111ello
str.insert(1, "111");
cout << str << endl;
//删除
//从第一个位置开始删除三个字符 删完后为hello
str.erase(1, 3);
cout << str << endl;
}
int main() {
test1();
system("pause");
return 0;
}
string字符串插入和删除
最新推荐文章于 2024-01-10 17:51:46 发布