原文:http://www.cnblogs.com/wangkangluo1/archive/2011/07/22/2114118.html
这些是我自己觉得常用的,具体查看原文
*string(const char *s); //用c字符串s初始化
*const char *c_str()const;//返回一个以null终止的c字符串,用printf(()输出时需要
*int size()const; //返回当前字符串的大小 int length()const; //返回当前字符串的长度 bool empty()const;
**string substr(int pos = 0,int n = npos) const;//返回pos开始的n个字符组成的字符串
**iterator erase(iterator it);//删除it指向的字符,返回删除后迭代器的位置
**int find(char c, int pos = 0) const;//从pos开始查找字符c在当前字符串的位置
**int find(const char *s, int pos = 0)const; //从pos开始查找字符串s在当前串中的位置
**string &replace(iterator first0, iterator last0,const char *s);//把[first0,last0)之间的部分替换为字符串s
**string &replace(iterator first0, iterator last0,const char *s, int n);//把[first0,last0)之间的部分替换为s的前n个字符
**string &insert(int p0,const string &s, int pos, int n);//在p0位置插入字符串s中pos开始的前n个字符
**iterator erase(iterator first, iterator last);//删除[first,last)之间的所有字符,返回删除后迭代器的位置
*string &insert(int p0, const char *s);
本文详细介绍了C++标准库中字符串(string)类的各种常用方法,包括初始化、查询、替换、插入与删除等操作,并提供了每种方法的具体使用方式。
307

被折叠的 条评论
为什么被折叠?



