std::wcsrchr
From cppreference.com
| ヘッダ <cwchar> で定義 |
||
| const wchar_t* wcsrchr( const wchar_t* str, wchar_t ch ); |
||
| wchar_t* wcsrchr( wchar_t* str, wchar_t ch ); |
||
ワイド文字列 str の中で、ワイド文字 ch の最後の出現箇所を検索します。
目次 |
[編集] パラメータ
| str | - | 解析対象のヌル終端ワイド文字列へのポインタ |
| 文字 | - | 検索するワイド文字 |
[編集] 戻り値
見つかった文字へのポインタ。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> の public メンバ関数) | |
| C言語のドキュメント (wcsrchr)
| |