std :: string :: find_first_not_of

公共成员函数
<字符串>

std :: string :: find_first_not_of

字符串(1)
size_t find_first_not_of(const string&str,size_t pos = 0)const;
c-string(2)
size_t find_first_not_of(const char * s,size_t pos = 0)const;
缓冲区(3)
size_t find_first_not_of(const char * s,size_t pos,size_t n)const;
人物(4)
size_t find_first_not_of(char c,size_t pos = 0)const;
字符串(1)
size_t find_first_not_of(const string&str,size_t pos = 0)const noexcept;
c-string(2)
size_t find_first_not_of(const char * s,size_t pos = 0)const;
缓冲区(3)
size_t find_first_not_of(const char * s,size_t pos,size_t n)const;
人物(4)
size_t find_first_not_of(char c,size_t pos = 0)const noexcept;

查找字符串中没有字符
字符串中 搜索与其参数中指定的任何字符不匹配的第一个字符。

POS 指定,搜索仅包括字符或在后位置 POS ,忽略字符之前的任何可能发生。

参数

海峡
另一个 字符串 ,包含要在搜索中使用的一组字符。
POS
搜索中要考虑的字符串中第一个字符的位置。
如果这大于 字符串长度 ,函数永远不会找到匹配。
注意:第一个字符的值为 0 (不是 1 ):值为 0 意味着搜索整个字符串。
小号
指向一组字符的指针。
如果指定了参数 (3) ,则在搜索中使用数组中的前 n个 字符。
否则 (2) ,预计会出现空终止的序列:搜索中使用的字符序列的长度由空字符的第一次出现决定。
ñ
要搜索的字符值的数量。
C
个人角色被搜索。

为size_t  是一个无符号整型(与成员类型相同)  字符串:: SIZE_TYPE )。

返回值

第一个字符的位置不匹配。
如果没有找到这样的字符,函数返回 string :: npos

为size_t  是一个无符号整型(与成员类型相同)  字符串:: SIZE_TYPE )。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// string::find_first_not_of
#include <iostream>       // std::cout
#include <string>         // std::string
#include <cstddef>        // std::size_t

int main ()
{
  std::string str ("look for non-alphabetic characters...");

  std::size_t found = str.find_first_not_of("abcdefghijklmnopqrstuvwxyz ");

  if (found!=std::string::npos)
  {
    std::cout << "The first non-alphabetic character is " << str[found];
    std::cout << " at position " << found << '\n';
  }

  return 0;
}


第一个非字母字符是 - 在位置12

复杂

未指定,但通常达到线性 长度() -pos 次匹配的字符数(最坏的情况)。

迭代器的有效性

没有变化。

数据竞赛

该对象被访问。

异常安全

如果 s 不足以指向数组,则会导致 未定义的行为
否则,该函数不会抛出异常(无丢包保证)。

也可以看看

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值