名稱空間
變體
操作

wcspbrk

來自 cppreference.com
< c‎ | string‎ | wide
在標頭檔案 <wchar.h> 中定義
wchar_t *wcspbrk( const wchar_t *dest, const wchar_t *str );
(1) (自 C95 起)
/*QWchar_t*/ *wcspbrk( /*QWchar_t*/ *dest, const wchar_t *str );
(2) (自 C23 起)
1)dest 指向的寬字串中查詢第一個同時存在於 str 指向的寬字串中的字元。
2) 等同於 (1) 的型別泛型函式。令 T 為不帶限定符的寬字元物件型別。
  • 如果 dest 的型別是 const T*,則返回型別是 const wchar_t*
  • 否則,如果 dest 的型別是 T*,則返回型別是 wchar_t*
  • 否則,行為未定義。
如果這些泛型函式的宏定義被抑制以訪問實際函式(例如,如果使用 (wcspbrk) 或函式指標),則實際函式宣告 (1) 將可見。

目錄

[編輯] 引數

dest - 指向待分析的空終止寬字串的指標
src - 指向包含要搜尋的字元的空終止寬字串的指標

[編輯] 返回值

指向 dest 中第一個同時存在於 str 中的字元的指標,如果不存在此類字元,則返回空指標。

[編輯] 注意

這個名稱代表“寬字元字串指標中斷”,因為它返回一個指向第一個分隔(“中斷”)字元的指標。

[編輯] 示例

#include <stdio.h>
#include <wchar.h>
 
int main(void)
{
    const wchar_t* str = L"Hello world, friend of mine!";
    const wchar_t* sep = L" ,!";
 
    unsigned int cnt = 0;
    do {
       str = wcspbrk(str, sep); // find separator
       if (str) str += wcsspn(str, sep); // skip separator
       ++cnt; // increment word count
    } while (str && *str);
 
    wprintf(L"There are %u words.\n", cnt);
}

輸出

There are 5 words.

[編輯] 參考

  • C11 標準 (ISO/IEC 9899:2011)
  • 7.29.4.5.3 wcspbrk 函式 (p: 436)
  • C99 標準 (ISO/IEC 9899:1999)
  • 7.24.4.5.3 wcspbrk 函式 (p: 382)

[編輯] 另請參閱

返回由另一個位元組字串中找到的字元組成的最大初始段的長度
僅包含在另一個寬字串中未找到的寬字元
(函式) [編輯]
(C95)
在寬字串中查詢寬字元的首次出現
(函式) [編輯]
在一個字串中查詢另一個字串中任意字元的第一個位置
(函式) [編輯]
C++ 文件 for wcspbrk