std::wcspbrk
来自 cppreference.cn
定义于头文件 <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 中的字符的指针;如果不存在这样的字符,则返回空指针。
[编辑] 注释
名称 "wcspbrk" 代表 "wide character string pointer break"(宽字符串指针断点),因为它返回指向第一个分隔符(“断点”)字符的指针。
[编辑] 示例
运行此代码
#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); // find separator std::wcout << std::quoted(str) << L'\n'; if (str) str += std::wcsspn(str, sep); // skip separator ++cnt; // increment word count } 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
[编辑] 参见
返回由...组成的最大初始段的长度 仅由不在另一个宽字符串中找到的宽字符组成 (函数) | |
在宽字符串中查找宽字符的首次出现 (函数) | |
查找来自分隔符集合的任何字符的第一个位置 (函数) | |
C 文档 for wcspbrk
|