wcspbrk
From cppreference.net
|
定义于头文件
<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); // 查找分隔符 if (str) str += wcsspn(str, sep); // 跳过分隔符 ++cnt; // 增加单词计数 } while (str && *str); wprintf(L"There are %u words.\n", cnt); }
输出:
There are 5 words.