string::find_first_not_of
| string (1) |
size_t find_first_not_of (const string& str, size_t pos = 0) const noexcept; |
|---|---|
| c-string (2) |
size_t find_first_not_of (const char* s, size_t pos = 0) const; |
| buffer (3) |
size_t find_first_not_of (const char* s, size_t pos, size_t n) const; |
| character (4) |
size_t find_first_not_of (char c, size_t pos = 0) const noexcept; |
功能:查找在前面出现后面没有的位置
返回值:成功返回找到的位置,没找到返回string::npos
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1("abcde");
string s2("aaccbbddeeff");
size_t n = s2.find_first_not_of(s1);
cout << n << endl;
const char *s3 = "abcdefghij";
string s4("mabcdefghijk");
cout << s4.find_first_not_of(s3) << endl;
cout << s4.find_first_not_of(s3, 1) << endl;
cout << s4.find_first_not_of(s3, 1, 5) << endl;
string s5("mabcdefghij");
cout << (n = s5.find_first_not_of(s3, 1)) << endl;
if(n == string::npos)
cout << "not found diffence string::npos" << endl;
return 0;
}
string::find_first_not_of的更多相关文章
- 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/C++
source code https://github.com/haotang923/interview/blob/master/interview%20summary%20of%20C%20and%2 ...
- STL顺序容器用法自我总结
顺序容器类型:vector.deque.list.forward_list.string.array. queue(单向队列)底层也是用deque(双端队列)实现的 a.swap(b); swap(a ...
- c++ string 之 find_first_not_of 源码
一:实现之前先说一所find_first_not_of姊妹函数() (1)find_first_of(string &str, size_type index = 0):(find_first ...
- string类find_first_not_of ()方法
string类find_first_not_of ()方法 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://xfqxj.blog. ...
- 标准C++中的string类的用法总结
标准C++中的string类的用法总结 相信使用过MFC编程的朋友对CString这个类的印象应该非常深刻吧?的确,MFC中的CString类使用起来真的非常的方便好用.但是如果离开了MFC框架,还有 ...
随机推荐
- 英特尔® 图形性能分析器 2019 R1 版本
了解并下载全新英特尔® 图形性能分析器 2019 R1 版本.新版本新增了 DX11 和 Vulkan 多帧流捕获模式,可以在“帧和图形跟踪分析器”中分析 Vulkan 应用.此外,帧分析器还添加了 ...
- javascrit-function中this的指向问题
javascrit中this的指向 全局作用域或者普通函数中 this 指向全局对象 window. //直接打印 console.log(this) //window //function声明函数 ...
- 深入源码分析Spring中的构造器注入
# 1. 示例 构造器注入类,分别有三个构造器,一个是无参构造器,一个是注入一个Bean的构造器,一个是注入两个Bean的构造器: public class ConstructorAutowiredT ...
- Linux常用目录名称
目录 用途 / 虚拟目录的根文件,通常不会在这里存储文件 /bin 二进制目录,存放许多用户的GNU工具 /boot 启动目录,存放启动文件 /dev 设备目录,Linux在这里创建设备节点 /etc ...
- Leetcode之动态规划(DP)专题-931. 下降路径最小和(Minimum Falling Path Sum)
Leetcode之动态规划(DP)专题-931. 下降路径最小和(Minimum Falling Path Sum) 给定一个方形整数数组 A,我们想要得到通过 A 的下降路径的最小和. 下降路径可以 ...
- 【Linux开发】linux设备驱动归纳总结(三):7.异步通知fasync
linux设备驱动归纳总结(三):7.异步通知fasync xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...
- Construct String from Binary Tree
You need to construct a string consists of parenthesis and integers from a binary tree with the preo ...
- 查找担保圈-step1-担保圈表函数
USE [test]; GO /****** Object: UserDefinedFunction [dbo].[f_findrecycle] Script Date: 2019/7/8 14:37 ...
- EM 算法(一)-原理
讲到 EM 算法就不得不提极大似然估计,我之前讲过,请参考我的博客 下面我用一张图解释极大似然估计和 EM 算法的区别 EM 算法引例1-抛3枚硬币 还是上图中抛硬币的例子,假设最后结果正面记为1,反 ...
- jQuery可拖拽旋转的3D图片墙
在线演示 本地下载