wmemchr
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <wchar.h> で定義
|
||
wchar_t *wmemchr( const wchar_t *ptr, wchar_t ch, size_t count ); |
(C95以上) | |
ptr の指すワイド文字配列 (または互換性のある型の整数配列) の先頭 count 個のワイド文字からワイド文字 ch が最初に現れる位置を探します。
count がゼロの場合、この関数はヌルポインタを返します。
引数
| ptr | - | 調べるワイド文字配列を指すポインタ |
| ch | - | 検索するワイド文字 |
| count | - | 調べるワイド文字数 |
戻り値
ワイド文字の位置を指すポインタ、またはそのような文字が見つからない場合はヌルポインタ。
例
Run this code
#include <stdio.h>
#include <wchar.h>
#include <locale.h>
int main(void)
{
wchar_t str[] = L"诺不轻信,故人不负我\0诺不轻许,故我不负人。";
size_t sz = sizeof str / sizeof *str;
wchar_t target = L'许';
wchar_t* result = wmemchr(str, target, sz);
if (result) {
setlocale(LC_ALL, "en_US.utf8");
printf("Found '%lc' at position %td\n",target, result - str);
}
}
出力例:
Found '许' at position 14