std::wcsspn
来自 cppreference.cn
在头文件 <cwchar> 中定义 |
||
size_t wcsspn( const wchar_t* dest, const wchar_t* src ); |
||
返回由 dest 指向的宽字符串的最大初始段的长度,该初始段仅由 src 指向的宽字符串中找到的字符组成。
目录 |
[编辑] 参数
dest | - | 指向待分析的空终止宽字符串的指针 |
src | - | 指向包含要搜索的字符的空终止宽字符串的指针 |
[编辑] 返回值
包含仅来自 src 指向的宽字符串的字符的最大初始段的长度。
[编辑] 示例
运行此代码
#include <cwchar> #include <iostream> #include <locale> int main() { wchar_t dest[] = L"白猫 黑狗 甲虫"; const wchar_t src[] = L" 狗猫 白黑 "; const std::size_t len = std::wcsspn(dest, src); dest[len] = L'\0'; // terminates the segment to print it out std::wcout.imbue(std::locale("en_US.utf8")); std::wcout << L"The length of maximum initial segment is " << len << L".\n"; std::wcout << L"The segment is \"" << dest << L"\".\n"; }
可能的输出
The length of maximum initial segment is 6. The segment is "白猫 黑狗 ".
[编辑] 参阅
返回由另一个字节字符串中找到的字符组成的最大初始段的长度 仅当另一个宽字符串中未找到宽字符时 (函数) | |
在另一个宽字符串中查找一个宽字符串中任意宽字符的首次出现位置 (函数) | |
wcsspn 的 C 文档
|