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框架,还有 ...
随机推荐
- web service----调用第三方接口
1. 什么是Web Service呢?从表面上看,WebService就是一个应用程序,它向外界暴露出一个能够通过Web进行调用的API.这就是说,你能够用编程的方法通过Web调用来实现某个功能的应用 ...
- java:JQuery(Ajax,JSON)
1.遍历ajax返回的json: 第一种: <%@ page language="java" import="java.util.*" pageEncod ...
- 了解XPath与XPath轴
XPath 是一门在 XML 文档中查找信息的语言.XPath 用于在 XML 文档中通过元素和属性进行导航. 节点(Node) 在 XPath 中,有七种类型的节点:元素.属性.文本.命名空间.处理 ...
- 【AMAD】schema -- 使用pythonic的方式进行schema验证
动机 简介 用法 个人评分 动机 验证数据是否符合规范是很有用的,比如: 用于单元测试 用于验证用户提交的数据是否合法 简介 schema1是一个用来验证python数据结构的库. 可以用来验证诸如: ...
- IDEA添加Lombok插件
背景: 最近老大给了一个项目,是个雏.一看实体类就懵逼了,没有getter.setter和构造方法,导致service和controller全报红线,私有属性也没有注释.按规矩,心里先把这位前辈骂10 ...
- 【VS开发】【DSP开发】浅谈Linux PCI设备驱动(二)
我们在 浅谈Linux PCI设备驱动(一)中(以下简称 浅谈(一) )介绍了PCI的配置寄存器组,而Linux PCI初始化就是使用了这些寄存器来进行的.后面我们会举个例子来说明Linux PCI设 ...
- LCA模板(数剖实现)
题目链接:https://www.luogu.org/problemnew/show/P3379 题意:LCA模板题. 思路:今天开始学树剖,先拿lca练练.树剖解lca,两次dfs复杂度均为O(n) ...
- [转帖]IntelliJ IDEA 2018.3.3破解方法
IntelliJ IDEA 2018.3.3破解方法 https://blog.csdn.net/qq_42862882/article/details/86477495 验证了下 也可以激活. ...
- [转帖]U盘安装centos 的方法
通过U盘或CD/DVD装centos7,出现“dracut-initqueue timeout..."解决办法 1.在用CD/DVD挂载centos7镜像安装系统时,出现“dracut- ...
- python 求从1加到100的和,join的用法
li=[] def func3(x): li.append(str(x)) if x==1: return 1 return x+func3(x-1) # print(func3(100)) re=f ...