wcspbrk
来自 cppreference.cn
| 在头文件 <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 中的字符的指针,如果不存在此类字符,则返回空指针。
[编辑] 注意
这个名称代表“宽字符字符串指针中断”,因为它返回一个指向第一个分隔(“中断”)字符的指针。
[编辑] 示例
运行此代码
#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.