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 官宣新年祝福语简短