string类函数追加
string s1{"hello world");
s1.append("welcome",3,2);//从第三个位置开始后的两个位置。
s1.append("welcome",5);//从开头起始;
s1.append(4,'g');//将字符重复多少遍;
at(index)//返回当前字符串中index位置的字符;
clear();//清空字符串
erase(index,n);//删除字符串从index起的n个字符;
empty();//判断字符串是否为空;
//
compare
sring s1{"hello"};
string s2{"helle"}
cout<<s1.compare(s2);//如果不相等则返回非零值,否则0
//
substr(用于获取字符串);
string s1{"welcome"};
cout<<s1.substr(1,2)<<endl;//输出从1号位置开始的2个字符;
cout<<s1.substr(3)<<endl;//输出从3号位置开始一直到最末位置;
//
find(用于搜索字符串);
cout<<s1.find("co")<<endl;//返回字符串中第一个出现co的位置;
cout<<s1.find("co",6)<<endl;//从第六个位置开始检索,返回第一个出现co的位置;
cout<<s1.find('c');
//
insert(用于插入字符串);
repalce(替换字符);