string::find_last_of
今天在代码中用到string的这个方法,一不小心就用错了。

这是http://www.cplusplus.com/关于这个方法的解释。
Searches the string for the last character that matches any of the characters specified in its arguments.
When pos is specified, the search only includes characters at or before position pos, ignoring any possible occurrences after pos.
这里解释说:在指定的字符串中搜索最靠后的任意匹配的字符或者字符串,如果指定了pos,那么搜索范围只会在pos之前以及pos处的字符,不会考虑之后的字符。
我就错了这个地方,我以为搜索不会搜索pos处的字符呢
要小心这些细节处的东西,否则会让你很难受呢,感觉自己代码写对了,但是结果就是不对,主要还是对C++库的使用不熟练。
string::find_last_of的更多相关文章
- string find_last_of 用法
int find_first_of(char c, int start = 0): 查找字符串中第1个出现的c,由位置start开始. 如果有匹配, ...
- C++string中find,find_first_of和find_last_of的用法
1. size_t find (const string& str, size_t pos = 0) str.find(str1) 说明:从pos(默认是是0,即从头开始查找)开始查找,找到第 ...
- leetcode345——Reverse Vowels of a String(C++)
Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Giv ...
- C++ string 类详解
字符串是存储在内存的连续字节中的一系列字符.C++ 处理字符串的方式有两种,一种来自 C 语言,常被称为 C-风格字符串,另一种是基于 string 类库的字符串处理方式.C 风格字符串的处理可以参考 ...
- std::string::find_last_not_of
public member function <string> std::string::find_last_not_of C++98 C++11 string (1) size_t fi ...
- 关于string类中find函数的讲解
以下所讲的所有的string查找函数,都有唯一的返回类型,那就是size_type,即一个无符号整数(按打印出来的算).若查找成功,返回按查找规则找到的第一个字符或子串的位置:若查找失败,返回npos ...
- C++ string类型小结
目录 构造函数 string.append() string.assign() string.at() string.back() string.begin() string.capasity() s ...
- C++编程优化心得(持续更新)
1. 对齐原则.比如64位总线,每次寻址读取8B.编程时注意变量地址,尽量消耗总线最少的寻址次数.堆内存申请时,系统严格按照对齐原则分配,故而使用时候也尽量不要跨寻址边界. 2. 需要的时候,可为了效 ...
- c++中级 STL基础学习(二)
deque 和vector差不多,可以在前端后端插入,一般用deque取代vector,vector只能在后端插入push_back().deque还可以push_front(),但是deque后端插 ...
随机推荐
- 【记忆化搜索】bzoj1079 [SCOI2008]着色方案
#include<cstring> #include<cstdio> using namespace std; #define MOD 1000000007 typedef l ...
- codevs与noi做题改错本目录
从2016.2.13开始: 1. 排序超时的问题---------目录:-测试习题 2. 超高精度乘法超时问题-----------目录:高精度计算 算法:快速傅里叶算法. 压位算法 3. 高精度 ...
- Spring整合jdbc-jdbc模板api详解
1, package com.songyan.jdbc2; public class User { private int id; private String name; public int ge ...
- Android中的动态字符串的处理
1.效果显示 2. MainAcitivity.java package com.example.app2; import android.support.v7.app.AppCompatActivi ...
- php获取两个日期之间的所有日期
function getDates($start, $end) { $dt_start = strtotime($start); $dt_end = strtotime($end); do{ echo ...
- 关于数字、数据处理的几个PHP函数汇总
1. / 得到的结果是浮点数 2. % 求余数 3.ceil():得到大于当前数字的整数 $num=3.4; $num=ceil($num); echo $num; 的到的结果是4 $num=3. ...
- Swift,初始化
1.class中的值是没办法不赋值,不然会报错,那么就有个init的方法初始化(这个方法使得实例时必须加上参数) class test{ var a:String var b:Int init(a:S ...
- css活用,评分点击星星
1.字符图集 2.css样式 .cleanfloat::after{display: block; clear: both; content:""; visibility: hid ...
- 【Todo】Apache-Commons-Pool及对象池学习
有这篇文章: http://www.cnblogs.com/tommyli/p/3510095.html 方案提供了三种类型的pool,分别是GenericKeyedObjectPool,SoftRe ...
- 集成方法:渐进梯度回归树GBRT(迭代决策树)
http://blog.csdn.net/pipisorry/article/details/60776803 单决策树C4.5由于功能太简单.而且非常easy出现过拟合的现象.于是引申出了很多变种决 ...