wcspbrk
来自cppreference.com
                    
                                        
                    
                    
                                                            
                    | 在标头  <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*。
- 否则,行为未定义。
 
-  若 
参数
| dest | - | 指向要分析的空终止宽字符串的指针 | 
| src | - | 指向含有待搜索字符的空终止宽字符串的指针 | 
返回值
指向 dest 中首个亦在 str 中的首个字符的指针,或若这种字符不存在则为空指针。
注解
名字代表“宽字符串指针打断 (wide character string pointer break)”,因为它返回指向首个分隔符(“打断”)的指针。
示例
运行此代码
#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); // 寻找分隔符 if (str) str += wcsspn(str, sep); // 跳过分隔符 ++cnt; // 增加词计数 } while (str && *str); wprintf(L"There are %u words.\n", cnt); }
输出:
There are 5 words.