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 ...
随机推荐
- redis 之django-redis
redis之django-redis 自定义连接池 这种方式跟普通py文件操作redis一样,代码如下: views.py import redis from django.shortcuts i ...
- redis-benchmark使用说明
Redis-benchmark为Redis性能测试工具. 指令说明: Usage: redis-benchmark [-h <host>] [-p <port>] [-c &l ...
- OpenStack组件——cinder存储服务
1.cinder 介绍 1)理解 Block Storage 操作系统获得存储空间的方式一般有两种: (1)通过某种协议(SAS,SCSI,SAN,iSCSI 等)挂接裸硬盘,然后分区.格式化.创建文 ...
- 5分钟了解图数据库Neo4j的使用
1.图数据库安装与配置 1.1安装与配置 配置path = %NEO4J_HOME%\bin 启动命令:neo4j console web访问:http://localhost:7474 1. ...
- 【Linux开发】linux中关于dma_alloc_coherent的用法
大家都知道,DMA的操作是需要物理地址的,但是在linux内核中使用的都是虚拟地址,如果我们想要用DMA对一段内存进行操作,我们如何得到这一段内存的物理地址和虚拟地址的映射呢?dma_alloc_co ...
- 【Linux开发】linux设备驱动归纳总结(三):6.poll和sellct
linux设备驱动归纳总结(三):6.poll和sellct xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...
- Linux实用技巧
1. linux共享内存的查看和释放 查看共享内存命令:ipcs -m 删除共享内存明明:ipcrm -m [shmid] [negivup@negivup mycode]$ ipcs -m 查看共 ...
- 如何解决Oracle11g使用dmp命令无法导出空表问题
如何解决Oracle11g使用dmp命令无法导出空表问题 导出:exp username/password@orcl file=路径 tables=(tb1) //tables=(tb1)可有 ...
- 结合docker做flask+kafka数据接口与压力测试
一.需求 需要做实时数据接入的接口.数据最终要写入库,要做到高并发,数据的完整,不丢失数据. 二.技术选型 1.因为只是做简单的接口,不需要复杂功能,所以决定用flask这个简单的python框架(因 ...
- Spring(十二)--Spring AspectJ
Spring AspectJ AspectJ是一个面向切面的框架,它扩展了Java语言.AspectJ定义了AOP语法,所以它有一个专门的编译器用来生成遵守Java字节编码规范的Class文件. As ...