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 生女孩红包简短祝福语