c++string的erase方法
来源:互联网 发布:土木工程翻译软件 编辑:程序博客网 时间:2024/06/05 15:48
erase函数的原型如下:(1)string& erase ( size_t pos = 0, size_t n = npos );(2)iterator erase ( iterator position );(3)iterator erase ( iterator first, iterator last );也就是说有三种用法:(1)erase(pos,n); 删除从pos开始的n个字符,比如erase(0,1)就是删除第一个字符(2)erase(position);删除position处的一个字符(position是个string类型的迭代器)(3)erase(first,last);删除从first到last之间的字符(first和last都是迭代器)下面给你一个例子:#include <iostream>
#include <string>using namespace std;int main (){ string str ("This is an example phrase."); string::iterator it; // 第(1)种用法 str.erase (10,8); cout << str << endl; // "This is an phrase." // 第(2)种用法 it=str.begin()+9; str.erase (it); cout << str << endl; // "This is a phrase." // 第(3)种用法 str.erase (str.begin()+5, str.end()-7); cout << str << endl; // "This phrase." return 0;}
0 0
- c++string的erase方法
- string的erase方法
- string 的erase方法注意事项
- string erase的用法
- string的erase用法
- string的erase方法, 第一次见, 没什么好说的
- string erase函数的运用
- string.erase()
- erase方法的正确使用
- C++中string erase函数的使用
- C++中string erase函数的使用
- C++中string erase函数的使用
- C++中string erase函数的使用
- C++ 中string.erase() 的用法
- C++中string erase函数的使用
- C++中string erase函数的使用
- std::vector<string>的find();与erase();
- C++中string erase函数的使用
- C中二进制方式读取写入文件简单实验
- PHP学习之路之Smarty变量
- 热插拔:软件+硬件 自己的学习总结
- Android中使用File的时候File.separator的用法
- ubuntu 14.04 NFS环境搭建
- c++string的erase方法
- 置顶,关于我的博客文章说明
- CentOS7 安装tomcat7.x为系统服务器 Systemctl管理Tomcat
- iOS NSIvocation的简介与使用
- 几何画板调用计算器的方法是这样的
- Android存储方式-SharedPreferences
- CodeForces 547A--找循环节
- 微信扫码登陆过程。
- 2016年7月编程语言排行榜