string::find_first_of
| string (1) |
size_t find_first_of (const string& str, size_t pos = 0) const noexcept; |
|---|---|
| c-string (2) |
size_t find_first_of (const char* s, size_t pos = 0) const; |
| buffer (3) |
size_t find_first_of (const char* s, size_t pos, size_t n) const; |
| character (4) |
size_t find_first_of (char c, size_t pos = 0) const noexcept; |
功能:在后面的字符串中查找前面string的每个字符
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1("abcdef");
string s2("dgte");
size_t n = s1.find_first_of(s2);
cout << n << endl;
n = s1.find_first_of(s2, 4);
cout << n << endl;
const char *s3 = "hijfkmn";
n = s1.find_first_of(s3);
cout << n << endl;
n = s1.find_first_of(s3, 3, 4); //s3的前4个字符中查找从s1的位置3开始的字符
cout << n << endl;
n = s1.find_first_of('c',3);//从s1的位置3(第4个)开始查找‘c’
cout << n << endl;
return 0;
}
string::find_first_of的更多相关文章
- 高德地图引入库错误std::string::find_first_of(char const*, unsigned long, unsigned long) const"
一:std:编译器错误解决 二:错误提示 "std::string::find_first_of(char const*, unsigned long, unsigned long) con ...
- C++中string.find()函数,string.find_first_of函数与string::npos
查找字符串a是否包含子串b,不是用strA.find(strB) > 0而是strA.find(strB) != string:nposstring::size_type pos = strA. ...
- 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 风格字符串的处理可以参考 ...
- LeetCode 5:Given an input string, reverse the string word by word.
problem: Given an input string, reverse the string word by word. For example: Given s = "the sk ...
- UVa 1596 Bug Hunt (string::find && map && 模拟)
题意 : 给出几组由数组定义与赋值构成的编程语句, 有可能有两种BUG, 第一种为数组下标越界, 第二种为使用尚未定义的数组元素, 叫你找出最早出现BUG的一行并输出, 每组以' . '号分隔, 当有 ...
- 关于string类中find函数的讲解
以下所讲的所有的string查找函数,都有唯一的返回类型,那就是size_type,即一个无符号整数(按打印出来的算).若查找成功,返回按查找规则找到的第一个字符或子串的位置:若查找失败,返回npos ...
- C++ string类型小结
目录 构造函数 string.append() string.assign() string.at() string.back() string.begin() string.capasity() s ...
随机推荐
- Dapper 多表(三表以上)查询小技巧
在使用Dappr做查询的时候遇到多表查询,之前多是两张表,现在出现三张表或者更多.两表的时候使用splitOn进行分割,splitOn的默认值是Id.在我建库的时候,主键ID并不都是这个名字.当出现三 ...
- Java并发编程之程序运行堆栈分析
Java程序运行的堆栈分析 1.JVM运行时数据区 JVM通过加载class文件的数据来执行程序.JVM在运行时会划分不同的区域以存放数据.如下图所示: 线程共享部分:所有线程都能访问这块内存的数据, ...
- yum安装etcd集群
前一篇文章介绍了如何yum安装简单的kubernetes集群,其中etcd是单点部署.本篇我们来搭建etcd集群,方便日后搭建kubernetes HA集群架构. 1,环境配置说明 etcd1 ...
- IntelliJ IDEA 2018 for Mac专业使用技巧
IntelliJ IDEA 2018 for Mac是一个综合性的Java编程环境,被许多开发人员和行业专家誉为市场上最好的IDE,它提供了一系列最实用的的工具组合:智能编码辅助和自动控制,支持J2E ...
- SpringCloud(0) 外行人都能看懂的SpringCloud,错过了血亏!
一.前言 只有光头才能变强 认识我的朋友可能都知道我这阵子去实习啦,去的公司说是用SpringCloud(但我觉得使用的力度并不大啊~~)... 所以,这篇主要来讲讲SpringCloud的一些基础的 ...
- linux批量删除
find . -name "*.bcp" | xargs rm -rf "*.bcp"
- Jira和confluence备份
参考: https://www.cnblogs.com/kevingrace/p/8862531.html JIRA备份和还原: #Jira默认会打开自动备份的功能,备份路径为: /data/atl ...
- hive_UDTF函数
hive的UDTF函数是可以输入一行数据然后输出多行多列(可以是单行/单列)的函数 public class Tex extends GenericUDTF { /** * 对传入的参数进行初始化 * ...
- LOJ576 「LibreOJ NOI Round #2」签到游戏
题目 先进行一个转化: 每次花费\(\gcd\limits_{i=l+1}^rB_i\)的代价,可以连\((l,r)\)这一条边. 然后我们需要求\(0\sim n\)的最小生成树. 根据Kruska ...
- JVM 线上故障排查基本操作 (转)
前言 对于后端程序员,特别是 Java 程序员来讲,排查线上问题是不可避免的.各种 CPU 飚高,内存溢出,频繁 GC 等等,这些都是令人头疼的问题.楼主同样也遇到过这些问题,那么,遇到这些问题该如何 ...