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框架,还有 ...
随机推荐
- MVC 表单防伪,自定义提示(AntiForgery.Validate)
再以前的文章解释过@Html.AntiForgeryToken()的部分源码,地址 直奔主题 <form id="form" action=""> ...
- Laravel底层原理系列
Laravel 从学徒到工匠精校版 地址:https://laravelacademy.org/laravel-from-appreciate-to-artisan Advanced Applicat ...
- 【学习笔记】使用python将最新的测试报告以附件的形式发到指定邮箱
import smtplib, email, os, timefrom email.mime.multipart import MIMEMultipartfrom email.mime.text im ...
- Django视图之FBV与CBV
一. CBV与FBV CBV:Class Based View FBV:Function Based View 我们之前写过的都是基于函数的view,就叫FBV.还可以把view写成基于类的,那就是C ...
- Leetcode之动态规划(DP)专题-877. 石子游戏(Stone Game)
Leetcode之动态规划(DP)专题-877. 石子游戏(Stone Game) 亚历克斯和李用几堆石子在做游戏.偶数堆石子排成一行,每堆都有正整数颗石子 piles[i] . 游戏以谁手中的石子最 ...
- JAVA师徒架构班 - 带徒模式
(转: http://www.jeecg.org/forum.php?mod=viewthread&tid=2291&extra=page%3D1&page=1) 一个程序员技 ...
- JMS消息通信服务
什么是Java消息服务 Java消息服务指的是两个应用程序之间进行异步通信的API,它为标准消息协议和消息服务提供了一组通用接口,包括创建.发送.读取消息等,用于支持JAVA应用程序开发.在J2EE中 ...
- Java后端技术面试汇总(第二套)
1.Java相关 • Arraylist与LinkedList默认空间是多少:• Arraylist与LinkedList区别与各自的优势List 和 Map 区别:• 谈谈HashMap,哈希表解决 ...
- 类的函数成员之属性property
属性命名采用Pascal命名方式,每个单词的首字母大写.访问方式与访问类的公共字段类似. /// <summary> /// 字段 /// </summary> private ...
- LintCode 68---Binary Tree Postorder Traversal
/** * Definition of TreeNode: * public class TreeNode { * public int val; * public TreeNode left, ri ...