声明
string str;
string str[]; //字符串数组
访问/添加/删除
[]
str.begin()/str.end()/it
cin>>str; //获取一个单词遇到空格停止
getline (cin,str); //获取一行字符
+=对于字符串,字符有效,数字当成ascii码
str.insert()
str.insert( pos, str2 )
//在下标为pos的位置插入字符串str2
str.insert( it, it2 + l, it2 + r )
//向 str1 的任意迭代器 it 处插入字符串str2的[l, r)
str.erase()
str.erase( it )
str.erase( pos, len )//删除从pos位开始长度为len的字符串
str.erase( it + l, it + r )
函数
== != > < 按字典序
str.substr( pos, len ) //返回 pos 号位开始、长度为 len 的字串。
str.find()
str.find( str2 )
//在str里查找str2 返回其在str里第一次出现的下标 找不到返回-1
str.find( str2, pos )
//在str里pos位置开始查找
str.replace( pos, len, str2 )
//把str中下标为pos长度为len的字符串替换为str2
str.clear()
str.size()
str.empty()