std:: wmemchr
From ja.cppreference.net
|
定義先ヘッダ
<cwchar>
|
||
|
const
wchar_t
*
wmemchr
(
const
wchar_t
*
ptr,
wchar_t
ch,
std::
size_t
count
)
;
|
(1) | |
|
wchar_t
*
wmemchr
(
wchar_t
*
ptr,
wchar_t
ch,
std::
size_t
count
)
;
|
(2) | |
ワイド文字配列 ptr が指す先頭 count ワイド文字内で、ワイド文字 ch が最初に出現する位置を検索します。
count がゼロの場合、この関数はヌルポインタを返します。
目次パラメータ
戻り値ワイド文字の位置へのポインタ、またはそのような文字が見つからない場合はヌルポインタ。 例
このコードを実行
#include <clocale> #include <cwchar> #include <iostream> #include <locale> int main() { const wchar_t str[] = L"诺不轻信,故人不负我\0诺不轻许,故我不负人。"; wchar_t target = L'许'; const std::size_t sz = sizeof str / sizeof *str; if (const wchar_t* result = std::wmemchr(str, target, sz)) { std::setlocale(LC_ALL, "en_US.utf8"); std::wcout.imbue(std::locale("en_US.utf8")); std::wcout << "Found '" << target << "' at position " << result - str << '\n'; } } 出力例: Found '许' at position 14 関連項目
| ||||||||||||||||||||