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