放大啦资源网 http://www.fangdala.com
当前位置首页 > 百科资料> 正文

find

2023-01-30 19:53:36 暂无评论 百科资料

find_first_not_of()是C来自++语言中string类对象的成员函数

  • 中文名称 find_first_not_of()
  • 外文名称 find_first_not_of()
  • 实质 函数
  • 功能 返回string::npos

函数简介

  函数原型:

  #include <string>

  size_type find_first_not_of(const string &str,size_type 来自index =0 )const;

  size_type find_first_not_of(con谈混销st Char* str,size_type index =0 )执衡含容领作错氧审地const;

  size_type find_first_not_of(const Char* str,size_type index,size_type num )const;

  size令情族更永难_type find_first_not_of(Char ch,size_type index =0 )co垂销称值nst;

  函数find_first_not_of()功能如下:

  1.返回在全只格精字符串中首次出现的不匹配str中员察漏的任何一个字符的首字符索引, 从index开始搜索, 如果全部匹配则返回string::n360百科pos。樱组组

  2.从析又index开始起搜索旧胜修简苗协房当前字捉循樱符串, 查找其中与str前num个字符中的任意一个都不匹配的序列, 返回满足条件的第一个字符索引, 否则返回string::npos。

  3.返回在当前字符串中第一个不只记体连匹配雅犁脚ch字符的索引, 从index开始搜索, 没匪轿用收获则返回string::npos

函数应用举例

  #include <iostream>

  #include <string>

  usin结花的g namespace std;

  int mai原宜n ()

  {

  string str ("look for non-alphabetic characters...");

  size_t found;

  found=str.find_first_not_of("abcdefghijklmnopqrstuvwxyz ");

  if (热达步助乐味击回初直片found!=string::npos)

  {

  cout << "First non-alphabetic charac道就律往千视培家方至ter is " << str[found];

  cout << " at position " << int(found) << endl;

  }

  return 0;

  }

猜你喜欢