std::wcspbrk
From cppreference.com
| ヘッダ <cwchar> で定義 |
||
| const wchar_t* wcspbrk( const wchar_t* dest, const wchar_t* src ); |
||
| wchar_t* wcspbrk( wchar_t* dest, const wchar_t* src ); |
||
dest が指すワイド文字列の中で、src が指すワイド文字列にも含まれる最初の文字を探します。
目次 |
[edit] パラメータ
| dest | - | 解析対象のヌル終端ワイド文字列へのポインタ |
| src | - | 検索対象の文字を含むヌル終端ワイド文字列へのポインタ |
[edit] 戻り値
dest の中で src にも含まれる最初の文字へのポインタ。そのような文字が存在しない場合はヌルポインタ。
[edit] 注記
この名前は「ワイド文字列ポインタブレーク」を意味します。これは、区切り文字(「ブレーク」)の最初の文字へのポインタを返すためです。
[edit] 例
このコードを実行
#include <cwchar> #include <iomanip> #include <iostream> int main() { const wchar_t* str = L"Hello world, friend of mine!"; const wchar_t* sep = L" ,!"; unsigned int cnt = 0; do { str = std::wcspbrk(str, sep); // find separator std::wcout << std::quoted(str) << L'\n'; if (str) str += std::wcsspn(str, sep); // skip separator ++cnt; // increment word count } while (str && *str); std::wcout << L"There are " << cnt << L" words\n"; }
出力
" world, friend of mine!" ", friend of mine!" " of mine!" " mine!" "!" There are 5 words
[edit] 関連項目
| 以下から成る最大の初期セグメントの長さを返す 別のワイド文字列に含まれないワイド文字のみからなる (関数) | |
| ワイド文字列内でワイド文字が最初に現れる場所を見つける (関数) | |
| 区切り文字の集合の中からいずれかの文字が最初に出現する位置を見つける (関数) | |
| C言語ドキュメント (wcspbrk)
| |