C中的strspn()
该函数strspn()用于计算第二个字符串中存在的第一个字符串的子字符串的长度。它返回该子字符串的长度。
这是strspn()C语言的语法,
size_t strspn(const char *string1, const char *string2);
这是strspn()C语言的示例,
示例
#include <stdio.h>
#include<string.h>
int main() {
const char s1[] = "Helloworld!";
const char s2[] = "Hello";
int length = strspn(s1, s2);
printf("The length of string : %d", length);
return 0;
}输出结果
The length of string : 5
热门推荐
10 男生节搞笑简短祝福语
11 退休后祝福语简短护士
12 蛋糕祝福语简短闺蜜
13 学校生日祝福语简短独特
14 生日摆摊祝福语简短独特
15 给女儿生日简短祝福语
16 妈咪跟我生日祝福语简短
17 开盘大吉的简短祝福语
18 祝女儿六一祝福语简短