头文件:#include<string>
using namespace std;
一、构造函数
string(const char *s); //用字符串s初始化
string(int n,char c); //用n个字符c初始化
二、常用功能函数
1、int length()const; //返回当前字符串的长度
2、void resize(int len,char c);//把字符串当前大小置为len,并用字符c填充不足的部分
3、string &operator+=(const string &s);//把字符串s连接到当前字符串的结尾
4、string &append(const char *s); //把c类型字符串s连接到当前字符串结尾
5、string substr(int pos = 0,int n = npos) const;//返回pos开始的n个字符组成的字符串
6、void swap(string &s2); //交换当前字符串与s2的值
7、int find(const char *s, int pos = 0) const;//从pos开始查找字符串s在当前串中的位置
8、int rfind(const string &s,int pos = npos) const;
//从pos开始从后向前查找字符串s中前n个字符组成的字符串在当前串中的位置,成功返回所在位置,失败时返回string::npos的值
9、string &replace(int p0, int n0,const char *s);//删除从p0开始的n0个字符,然后在p0处插入串s
10、string &insert(int p0,const string &s, int pos, int n);
//前4个函数在p0位置插入字符串s中pos开始的前n个字符
11、iterator erase(iterator first, iterator last);//删除[first,last)之间的所有字符,返回删除后迭代器的位置