std:: wcspbrk
From cppreference.net
|
定义于头文件
<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 中的字符的指针,若不存在此类字符则返回空指针。
注释
该名称代表“宽字符字符串指针断点”,因为它返回指向第一个分隔符(“断点”)字符的指针。
示例
运行此代码
#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); // 查找分隔符 std::wcout << std::quoted(str) << L'\n'; if (str) str += std::wcsspn(str, sep); // 跳过分隔符 ++cnt; // 增加单词计数 } 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
参见
|
返回仅包含不在另一个宽字符串中的宽字符的最大起始段长度
(函数) |
|
|
在宽字符串中查找宽字符的首次出现
(function) |
|
|
查找分隔符集合中任意字符的首次出现位置
(function) |
|
|
C 文档
for
wcspbrk
|
|