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的更多相关文章

  1. 高德地图引入库错误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 ...

  2. C++中string.find()函数,string.find_first_of函数与string::npos

    查找字符串a是否包含子串b,不是用strA.find(strB) > 0而是strA.find(strB) != string:nposstring::size_type pos = strA. ...

  3. 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,即从头开始查找)开始查找,找到第 ...

  4. 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 ...

  5. C++ string 类详解

    字符串是存储在内存的连续字节中的一系列字符.C++ 处理字符串的方式有两种,一种来自 C 语言,常被称为 C-风格字符串,另一种是基于 string 类库的字符串处理方式.C 风格字符串的处理可以参考 ...

  6. 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 ...

  7. UVa 1596 Bug Hunt (string::find && map && 模拟)

    题意 : 给出几组由数组定义与赋值构成的编程语句, 有可能有两种BUG, 第一种为数组下标越界, 第二种为使用尚未定义的数组元素, 叫你找出最早出现BUG的一行并输出, 每组以' . '号分隔, 当有 ...

  8. 关于string类中find函数的讲解

    以下所讲的所有的string查找函数,都有唯一的返回类型,那就是size_type,即一个无符号整数(按打印出来的算).若查找成功,返回按查找规则找到的第一个字符或子串的位置:若查找失败,返回npos ...

  9. C++ string类型小结

    目录 构造函数 string.append() string.assign() string.at() string.back() string.begin() string.capasity() s ...

随机推荐

  1. docker解决没有vim问题

    正确(1)下载镜像,docker pull nginx(2)启动容器,docker run -d -p 8083:80 nginx[root@ceshi ~]# docker exec -it 8ca ...

  2. 电脑的sid

    SID的查询方法:1.Win键+R键,打开运行,输入CMD2.输入:whoami /user3.就可以看到本机的SID了 SID的修改方法1.下载NewSID软件,并打开 2.可以指定一个SID,也可 ...

  3. 华为HCNA乱学Round 12:NAT和easy IP

  4. 华为HCNA乱学Round 6:PVID,TAG,TRUNK

  5. 【DSP开发】【图像处理】Gray与YUV之间的转换关系

    标准的V4L2 API http://v4l.videotechnology.com/dwg/v4l2.pdf 在例程/home/dvevm_1_20/demos/ImageGray中,涉及到图像采集 ...

  6. js继承的方式及其优缺点

    js继承方法 前因:ECMAScript不支持接口继承,只支持实现继承 一.原型链 概念:每个构造函数都有一个原型对象,原型对象都包含一个指向构造函数的指针,而实例都包含一个指向原型对象的内部指针,让 ...

  7. python并发编程-进程理论-进程方法-守护进程-互斥锁-01

    操作系统发展史(主要的几个阶段) 初始系统 1946年第一台计算机诞生,采用手工操作的方式(用穿孔卡片操作) 同一个房间同一时刻只能运行一个程序,效率极低(操作一两个小时,CPU一两秒可能就运算完了) ...

  8. git 常用命令语句(个人笔记)

    切换账户 git config user.name xxxxx     查看用户名  ex: git config user.name tongjiaojiao   git config user.e ...

  9. luogu P3226 [HNOI2012]集合选数

    luogu 因为限制关系只和2和3有关,如果把数中2的因子和3的因子都除掉,那剩下的数不同的数是不会相互影响,所以每次考虑剩下的数一样的一类数,答案为每类数答案的乘积 如果选了一个数,那么2的因子多1 ...

  10. 21 Python之反射

    1.反射 主要是用到了4个函数(  用的最多的就是getattr()和 hasattr()  ): getattr()   从xxx对象中获取到xxx属性值 hasattr()  判断xxx对象中是否 ...