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 18岁的祝福语简短
16 五十二新年祝福语简短
17 小清新的祝福语简短
18 毕业贺卡老师祝福语简短