std:: memchr
| Localization library | |||||||||||||||||||||||||
| Regular expressions library (C++11) | |||||||||||||||||||||||||
| Formatting library (C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Functions | ||||||||||||||||||||||||||||||||||||
| Character classification | ||||||||||||||||||||||||||||||||||||
| Character manipulation | ||||||||||||||||||||||||||||||||||||
| Conversions to numeric formats | ||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||
| String manipulation | ||||||||||||||||||||||||||||||||||||
| String examination | ||||||||||||||||||||||||||||||||||||
| Character array functions | ||||||||||||||||||||||||||||||||||||
| Miscellaneous | ||||||||||||||||||||||||||||||||||||
|
定义于头文件
<cstring>
|
||
|
const
void
*
memchr
(
const
void
*
ptr,
int
ch,
std::
size_t
count
)
;
|
||
|
void
*
memchr
(
void
*
ptr,
int
ch,
std::
size_t
count
)
;
|
||
将 ch 转换为 unsigned char 类型,并在 ptr 所指向对象的前 count 个字节中(每个字节均解释为 unsigned char )定位该值的首次出现位置。
|
此函数的行为表现为按顺序读取字节,并在找到匹配字节时立即停止:如果 ptr 所指向的数组小于 count ,但在数组范围内找到了匹配项,则其行为是明确定义的。 |
(since C++17) |
目录参数
返回值指向该字节位置的指针,如果未找到该字节则为空指针。 示例搜索字符数组。
运行此代码
输出: search character found 参阅
| |||||||||||||||||