strspn() 函数在 C 语言中
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
广告
数据结构
计算机网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言
C++
C#
MongoDB
MySQL
Javascript
PHP