strspn
来自cppreference.com
| 在标头 <string.h> 定义
|
||
| |
||
返回 dest 所指向的空终止字节串的最大起始段(span)长度,段仅由 src 所指向的空终止字节字符串中找到的字符组成。
若 dest 或 src 不是指向空终止字节字符串的指针,则行为未定义。
参数
| dest | - | 指向要分析的空终止字节字符串的指针 |
| src | - | 指向含有要搜索的字符的空终止字节字符串的指针 |
返回值
仅由来自 src 所指向的空终止字节字符串的字符组成的最大起始段长度。
示例
Run this code
#include <stdio.h>
#include <string.h>
int main(void)
{
const char* string = "abcde312$#@";
const char* low_alpha = "qwertyuiopasdfghjklzxcvbnm";
size_t spnsz = strspn(string, low_alpha);
printf("跳过 '%s' 中的开头小写字母\n"
"剩余 '%s'\n", string, string + spnsz);
}
输出:
跳过 'abcde312$#@' 中的开头小写字母
剩余 '312$#@'
引用
- C23 标准(ISO/IEC 9899:2024):
- 7.24.5.6 The strspn function (第 TBD 页)
- C17 标准(ISO/IEC 9899:2018):
- 7.24.5.6 The strspn function (第 TBD 页)
- C11 标准(ISO/IEC 9899:2011):
- 7.24.5.6 The strspn function (第 369 页)
- C99 标准(ISO/IEC 9899:1999):
- 7.21.5.6 The strspn function (第 332 页)
- C89/C90 标准(ISO/IEC 9899:1990):
- 4.11.5.6 The strspn function
参阅
| 返回另一个字符串所不具有的字符分割的最大起始段长度 (函数) | |
(C95) |
返回仅由另一个宽字符串中出现的宽字符分隔的最长首段长度 (函数) |
| 查找字符串中的任意字符在另一个字符串中的首个位置 (函数) | |
strspn 的 C++ 文档
|