进程 中的 int find_first_not_of(stri

首页 / C++入门教程 / 进程 中的 int find_first_not_of(stri

此函数用于在字符串中搜索与该字符串中指定的任何字符都不匹配的第一个字符。

find_first_not_of - 语法

str1.find_first_not_of(str2);

find_first_not_of - 参数

str     - str是用于搜索的字符串。

pos    -  它定义开始搜索的位置。

n         -  标识要搜索的字符的字符数。

ch      -  它定义了要搜索的字符

find_first_not_of - 返回值

它返回不匹配的第一个字符的位置。

find_first_not_of - 例子1

让我们看一个简单的例子。

#include<iostream>
using namespace std;
int main()
{
string str = "Hello";
cout<< "String contains :" << str <<'\n';
            cout<< str.find_first_not_of("Hllo");
}   

输出:

String contains : Hello
1

find_first_not_of - 例子2

让我们看一个简单的示例,其中指定了开始搜索的位置。

#include<iostream>
using namespace std;
int main()
{
string str = "Welcome to the learnfk";
cout<< "String contains :" << str <<'\n';
cout<< str.find_first_not_of("COME",3);
return 0;
 }

输出:

String contains : Welcome to the learnfk
3

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

10x程序员工作法 -〔郑晔〕

Redis源码剖析与实战 -〔蒋德钧〕

玩转Vue 3全家桶 -〔大圣〕

去无方向的信 -〔小麥〕

说透低代码 -〔陈旭〕

遗留系统现代化实战 -〔姚琪琳〕

技术领导力实战笔记 2022 -〔TGO 鲲鹏会〕

结构思考力 · 透过结构看表达 -〔李忠秋〕

AI 应用实战课 -〔黄佳〕

好记忆不如烂笔头。留下您的足迹吧 :)