std::wcsstr
From cppreference.com
| ヘッダ <cwchar> で定義 |
||
| const wchar_t* wcsstr( const wchar_t* dest, const wchar_t* src ); |
||
| wchar_t* wcsstr( wchar_t* dest, const wchar_t* src ); |
||
dest が指すワイド文字列内で、ワイド文字列 src の最初の出現箇所を探します。終端のヌル文字は比較されません。
目次 |
[編集] パラメータ
| dest | - | 検査対象の、ヌル終端ワイド文字列へのポインタ |
| src | - | 検索対象の、ヌル終端ワイド文字列へのポインタ |
[編集] 戻り値
見つかった部分文字列の dest 内での最初の文字へのポインタ。そのような部分文字列が見つからない場合はヌルポインタを返します。 src が空文字列を指す場合、 dest を返します。
[編集] 例
このコードを実行
#include <clocale> #include <cwchar> #include <iostream> int main() { wchar_t const* origin = L"アルファ, ベータ, ガンマ, アルファ, ベータ, ガンマ."; wchar_t const* target = L"ベータ"; wchar_t const* result = origin; std::setlocale(LC_ALL, "en_US.utf8"); std::wcout << L"Substring to find: \"" << target << L"\"\n" << L"String to search: \"" << origin << L"\"\n\n"; for (; (result = std::wcsstr(result, target)) != nullptr; ++result) std::wcout << L"Found: \"" << result << L"\"\n"; }
実行結果の例
Substring to find: "ベータ" String to search: "アルファ, ベータ, ガンマ, アルファ, ベータ, ガンマ." Found: "ベータ, ガンマ, アルファ, ベータ, ガンマ." Found: "ベータ, ガンマ."
[編集] 関連項目
指定された部分文字列が最初に現れる位置を見つけるstd::basic_string<CharT,Traits,Allocator> の (public メンバ関数) | |
| 部分文字列が最初に出現する箇所を見つける (関数) | |
| ワイド文字列内でワイド文字が最初に現れる場所を見つける (関数) | |
| ワイド文字列内でワイド文字が最後に現れる場所を見つける (関数) | |
| C言語のドキュメント ( wcsstr について)
| |