strspn() 함수는 두 번째 문자열에 있는 첫 번째 문자열의 부분 문자열 길이를 계산하는 데 사용됩니다. 해당 부분 문자열의 길이를 반환합니다.
다음은 C 언어의 strspn() 구문입니다.
size_t strspn(const char *string1, const char *string2);
다음은 C 언어의 strspn() 예제입니다.
예시
#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