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 ...
随机推荐
- 【转】jstat命令查看jvm的GC情况 (以Linux为例)
[From]https://www.cnblogs.com/yjd_hycf_space/p/7755633.html jstat命令可以查看堆内存各部分的使用量,以及加载类的数量.命令的格式如下: ...
- django实现利用mailgun进行收发邮件
django窗口类运用和邮件收发 运用django窗口类来完成表单html 1 具体你看网址: https://www.cnblogs.com/guguobao/p/9322027.html 利用窗口 ...
- Qt QLabel添加cliked事件
#ifndef MYLABEL_H #define MYLABEL_H #include <QObject> #include <QLabel> class MyLabel : ...
- JavaScript参考DOM部分
目录 DOM完整版 DOM 介绍 节点 节点树 Node接口 属性 方法 NodeList 接口,HTMLCollection 接口 介绍 NodeList.prototype.length Node ...
- office web apps安装部署,配置https,负载均衡(五)配置服务器场
前提条件:您已经完成了域控制器的配置,拥有域账号,并且已经安装了OWA启动所需要的必要软件: 具体步骤可以参考: office web apps安装部署,配置https,负载均衡(一)背景介绍 off ...
- linux(centos7)下SVN服务器搭建
https://www.cnblogs.com/fuyuanming/p/6123395.html linux(centos)下SVN服务器如何搭建?说到SVN服务器,想必大家都知道,可以是在LINU ...
- __setattr__,__getattr__,__delattr__
class Foo: x = 1 def __init__(self,y): self.y = y def __getattr__(self,item): print("---->fr ...
- Spring MVC (二)注解式开发使用详解
MVC注解式开发即处理器基于注解的类开发, 对于每一个定义的处理器, 无需在xml中注册. 只需在代码中通过对类与方法的注解, 即可完成注册. 定义处理器 @Controller: 当前类为处理器 @ ...
- Elasticsearch-数值类型
Elasticsearch-数值类型 数值类型可以是浮点数,也可以是费浮点数.如果不需要小数,可以选择byte.short.int或者long.如果确实需要小数,可以选择float和double.这些 ...
- 利用微信web开发者工具调试企业微信页面
1.只有企业号的管理员才能调试. 2.勾选企业号的开发者工具(具体位置见下图,这个入口位置总是在变,一般来说,找到”微工作台“就能找到了) 3.下载web开发者工具 https://developer ...