std:: strspn
From cppreference.net
C++
Text processing library
| Localization library | |||||||||||||||||||||||||
| Regular expressions library (C++11) | |||||||||||||||||||||||||
| Formatting library (C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Null-terminated byte strings
| Functions | ||||||||||||||||||||||||||||||||||||
| Character classification | ||||||||||||||||||||||||||||||||||||
| Character manipulation | ||||||||||||||||||||||||||||||||||||
| Conversions to numeric formats | ||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||
| String manipulation | ||||||||||||||||||||||||||||||||||||
| String examination | ||||||||||||||||||||||||||||||||||||
| Character array functions | ||||||||||||||||||||||||||||||||||||
| Miscellaneous | ||||||||||||||||||||||||||||||||||||
|
定义于头文件
<cstring>
|
||
|
size_t strspn
(
const
char
*
dest,
const
char
*
src
)
;
|
||
返回指向 dest 的字节字符串的最大初始段(跨度)长度,该段仅包含指向 src 的字节字符串中的字符。
目录 |
参数
| dest | - | 指向待分析的空终止字节字符串的指针 |
| src | - | 指向包含待搜索字符的空终止字节字符串的指针 |
返回值
指向字节字符串 src 的最大初始段长度,该段仅包含来自该字节字符串的字符。
示例
运行此代码
#include <cstring> #include <iostream> #include <string> const char* low_alpha = "qwertyuiopasdfghjklzxcvbnm"; int main() { std::string s = "abcde312$#@"; std::size_t spnsz = std::strspn(s.c_str(), low_alpha); std::cout << "After skipping initial lowercase letters from '" << s << "'\nThe remainder is '" << s.substr(spnsz) << "'\n"; }
输出:
After skipping initial lowercase letters from 'abcde312$#@' The remainder is '312$#@'
参见
|
返回仅包含不在另一个字节字符串中的字符的
最大起始段的长度 (函数) |
|
|
返回仅包含在另一个宽字符串中的宽字符的
最大起始段的长度 (函数) |
|
|
查找分隔符集合中任意字符的首次出现位置
(函数) |
|
|
C 文档
for
strspn
|
|