stl String常用函数

原文: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);


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值