std:: wcschr
From cppreference.net
|
ヘッダーで定義
<cwchar>
|
||
|
const
wchar_t
*
wcschr
(
const
wchar_t
*
str,
wchar_t
ch
)
;
|
||
|
wchar_t
*
wcschr
(
wchar_t
*
str,
wchar_t
ch
)
;
|
||
ワイド文字列 str が指す文字列内で、ワイド文字 ch が最初に現れる位置を検索します。
目次 |
パラメータ
| str | - | 解析対象のヌル終端ワイド文字列へのポインタ |
| ch | - | 検索対象のワイド文字 |
戻り値
見つかった文字へのポインタを str 内で返します。該当する文字が見つからない場合はヌルポインタを返します。
例
このコードを実行
#include <cwchar> #include <iostream> #include <locale> int main() { const wchar_t arr[] = L"白猫 黒猫 кошки"; const wchar_t* cat = std::wcschr(arr, L'猫'); const wchar_t* dog = std::wcschr(arr, L'犬'); std::cout.imbue(std::locale("en_US.utf8")); if (cat) std::cout << "The character 猫 found at position " << cat - arr << '\n'; else std::cout << "The character 猫 not found\n"; if (dog) std::cout << "The character 犬 found at position " << dog - arr << '\n'; else std::cout << "The character 犬 not found\n"; }
出力:
The character 猫 found at position 1 The character 犬 not found
関連項目
|
指定された部分文字列の最初の出現を検索する
(
std::basic_string<CharT,Traits,Allocator>
の公開メンバ関数)
|
|
|
文字の最初の出現を検索する
(関数) |
|
|
ワイド文字列内のワイド文字の最後の出現を検索する
(関数) |
|
|
あるワイド文字列内の任意のワイド文字の最初の位置を別のワイド文字列で検索する
(関数) |
|
|
Cドキュメント
for
wcschr
|
|