首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::memchr

Defined in header <cstring>

const void* memchr( const void* ptr, int ch, std::size_t count );

void* memchr( void* ptr, int ch, std::size_t count );

皈依chunsigned char,并在初始值中定位该值的第一次出现。count字符%28解释为unsigned char所指对象的%29ptr...

参数

ptr

-

pointer to the object to be examined

ch

-

character to search for

count

-

number of characters to examine

返回值

指向字符位置的指针,或NULL如果找不到这样的角色。

搜索一组字符。

二次

代码语言:javascript
复制
#include <iostream>
#include <cstring>
 
int main()
{
    char arr[] = {'a','\0','a','A','a','a','A','a'};
    char *pc = (char*)std::memchr(arr,'A',sizeof arr);
    if (pc != NULL)
       std::cout << "search character found\n";
    else
       std::cout << "search character not found\n";
}

二次

产出:

二次

代码语言:javascript
复制
search character found

二次

另见

strchr

finds the first occurrence of a character (function)

findfind_iffind_if_not (C++11)

finds the first element satisfying specific criteria (function template)

c备忘录文件

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券