#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
int main(){
//字符串的插入操作用常用insert
string s1 = "abcde";
string s2 = "ABC";
//s1.insert(3,s2); //在字符串s1的第pos个位置前 插入字符串s2
//s1.insert(3,s2,0,2); //在字符串s1的第pos个位置前 插入字符串s2的从begin开始到end的前一个字符结束的子串
//s1.insert(3,2,'A'); //在字符串s1的第pos个位置前 插入n个字符c
//字符串的删除操作常用erase
//s1.erase(2); //删除字符串s从第pos个字符开始之后所有的字符(包括第pos个;
//s1.erase(1,2); //删除字符串s从第pos个字符开始的n个字符
//截取字符串
//string substr (size_t pos = 0, size_t len = npos) const;
// pos=截取起始位 en=截取长度
s2 = "ABCDEF";
//s1 = s2.substr(2); //截取下标从2(第3个字符)开始到字符串结尾的字符串
//s1 = s2.substr(s2.find_last_of("D")+1); //
/*
关于string::find_first_of()
string::find_first_not_of()
string::find_last_of()
string::find_last_not_of(),参考如下:
string str1 = "cup,car,person,car,booo";
string str2 = "ako";
int num_1 = str1.find_first_of(str2);//返回str1中第一个与str2的第一个字符('a')相同字符的下标 ,返回5
int num_2 = str1.find_first_not_of(str2);//返回str1中第一个与str2的第一个字符('a')不同字符的下标 ,返回0
int num_3 = str1.find_last_of(str2);//返回str1中最后一个与str2的最后一个字符('o')相同字符的下标 ,返回22
int num_4 = str1.find_last_not_of(str2);//返回str1中最后一个与str2的最后一个字符('o')不同字符的下标 ,返回19
注:如果str2中的对应字符(最后或者最前字符)不在str1中,将返回一个很大的数。
*/
//s1 = s2.substr(2,3); //截取下标从pos(第3个字符)开始截取3个字符的字符串
cout << s1 << endl;
return 0;
}
后期还有,见到了再补充吧