std:: wcsstr
From cppreference.net
|
ヘッダーで定義
<cwchar>
|
||
|
const
wchar_t
*
wcsstr
(
const
wchar_t
*
dest,
const
wchar_t
*
src
)
;
|
||
|
wchar_t
*
wcsstr
(
wchar_t
*
dest,
const
wchar_t
*
src
)
;
|
||
ワイド文字列 src が指すワイド文字列内で、最初に出現する dest を検索します。終端のnull文字は比較されません。
目次 |
パラメータ
| dest | - | 検査対象のnull終端ワイド文字列へのポインタ |
| src | - | 検索対象のnull終端ワイド文字列へのポインタ |
戻り値
見つかった部分文字列の最初の文字へのポインタを 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>
の公開メンバ関数)
|
|
|
文字の部分文字列の最初の出現を検索する
(関数) |
|
|
ワイド文字列内のワイド文字の最初の出現を検索する
(関数) |
|
|
ワイド文字列内のワイド文字の最後の出現を検索する
(関数) |
|
|
Cドキュメント
for
wcsstr
|
|