std::wcspbrk
來自 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 中的字元。
目錄 |
[編輯] 引數
dest | - | 指向待分析的空終止寬字串的指標 |
src | - | 指向包含要搜尋的字元的空終止寬字串的指標 |
[編輯] 返回值
指向 dest 中第一個同時存在於 src 中的字元的指標,如果不存在這樣的字元,則返回空指標。
[編輯] 注意
這個名稱代表“寬字元字串指標中斷(wide character string pointer break)”,因為它返回一個指向第一個分隔符(“中斷”)字元的指標。
[編輯] 示例
執行此程式碼
#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
[編輯] 參閱
返回由另一個位元組字串中找到的字元組成的最大初始段的長度 僅當另一個寬字串中未找到寬字元時 (函式) | |
在寬字串中查詢寬字元的首次出現 (函式) | |
查詢分隔符集中任何字元的第一個位置 (函式) | |
C 文件 關於 wcspbrk
|