#C 语言标准库函数 wmemchr
#include <wchar.h>
wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n);
说明
查找指定范围内首个等于 c 的宽字符。
空宽字符可作为普通数组元素查找。 C23 的类型通用调用保留被搜索对象的 const 限定,上面展示普通函数原型。
自 C95 起提供。
参数
s- 被查找的宽字符数组。按给定长度读取。c- 要找的宽字符值。n- 数组中参与查找的元素数。
返回值
- 匹配时返回原数组中的位置,未找到时返回空指针。
#示例
#include <wchar.h>
int main(void)
{
const wchar_t text[] = L"ABBA";
const wchar_t *match = wmemchr(text, L'B', 4);
return match != text + 1;
}