1.常常忘记加string 头文件

2.size和length函数没有区别,length函数是为了增强可读性

3.substr函数  s.substr(a,b)表示从a开始后的b位

  s.substr();//返回s的全部内容
  s.substr(11);//从索引11往后的子串
  s.substr(5,6);//从索引5开始6个字符

4.关于append函数和assign函数,append函数更偏向于添加,而assign更偏向于赋值。

s.append(5,'x')添加5个x;s.append(str,1,5)把str的1到5添加给s;

5.关于insert、erase函数

  s.insert(0,”my name”);

       s.insert(1,str);
  s.erase(13);//从索引13开始往后全删除
  s.erase(7,5);//从索引7开始往后删5个
6.关于find函数
  

  int find(char c, int pos = 0) const;//从pos开始查找字符c在当前字符串的位置
    int find(const char *s, int pos = 0) const;//从pos开始查找字符串s在当前串中的位置

int find(const char *s, int pos, int n) const;//从pos开始查找字符串s中前n个字符在当前串中的位置
int find(const string &s, int pos = 0) const;//从pos开始查找字符串s在当前串中的位置
//查找成功时返回所在位置,失败返回string::npos的值 
int rfind(char c, int pos = npos) const;//从pos开始从后向前查找字符c在当前串中的位置
int rfind(const char *s, int pos = npos) const;
int rfind(const char *s, int pos, int n = npos) const;
int rfind(const string &s,int pos = npos) const;
//从pos开始从后向前查找字符串s中前n个字符组成的字符串在当前串中的位置,成功返回所在位置,失败时返回string::npos的值 
int find_first_of(char c, int pos = 0) const;//从pos开始查找字符c第一次出现的位置
int find_first_of(const char *s, int pos = 0) const;
int find_first_of(const char *s, int pos, int n) const;
int find_first_of(const string &s,int pos = 0) const;
//从pos开始查找当前串中第一个在s的前n个字符组成的数组里的字符的位置。查找失败返回string::npos 
int find_first_not_of(char c, int pos = 0) const;
int find_first_not_of(const char *s, int pos = 0) const;
int find_first_not_of(const char *s, int pos,int n) const;
int find_first_not_of(const string &s,int pos = 0) const;
//从当前串中查找第一个不在串s中的字符出现的位置,失败返回string::npos 
int find_last_of(char c, int pos = npos) const;
int find_last_of(const char *s, int pos = npos) const;
int find_last_of(const char *s, int pos, int n = npos) const;
int find_last_of(const string &s,int pos = npos) const; 
int find_last_not_of(char c, int pos = npos) const;
int find_last_not_of(const char *s, int pos = npos) const;
int find_last_not_of(const char *s, int pos, int n) const;
int find_last_not_of(const string &s,int pos = npos) const;
//find_last_of和find_last_not_of与find_first_of和find_first_not_of相似,只不过是从后向前查找

最新文章

  1. update kernel 3.10-3.12
  2. Hello, Android多屏幕版
  3. 讨论一下js获取响应中后台传回来的BigInteger类型的数字时,后几位会自动变为0的问题
  4. Inside The C++ Object Model - 02
  5. 【转】【PNG压缩工具】PNG 图像的优化及压缩工具介绍
  6. C语言时间函数
  7. LOAD DATA INFILE – performance case study
  8. 非托管C++通过C++/CLI包装调用C# DLL
  9. uva 10994 - Simple Addition
  10. 开学&东大一周游记
  11. html网页的兼容性和css优先级
  12. 电铸3D18K硬金 电铸易熔合金 电铸中空硬金饰品合金
  13. 【Uva 11604 编码都有歧义了】
  14. js实用方法记录-指不定哪天就会用到的js方法
  15. JAVA-JSP内置对象之response对象实现页面跳转
  16. Bootstrap FileInput中文API文档
  17. Rsync启动停止脚本
  18. LINQ-Where子句与select子句
  19. mysql如何批量删除数据表
  20. js字符串和数组的相互转化

热门文章

  1. Laravel系列 Web
  2. 详解 JavaScript 中 splice() 方法
  3. C++高级 STL——模板函数、模板类
  4. C语言进阶——类型转换04
  5. ABAP 7.51 構文書き方変換について
  6. 分布式爬虫:使用Scrapy抓取数据
  7. idea 项目jar包出错
  8. jsUnpacker
  9. Maven学习 (二) Eclipse 上安装 Maven3插件
  10. 2.0 python+appium环境搭建