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 送给学长毕业祝福语简短