C strspn() Function

Last Updated:

C strspn()

The strspn() function finds up to what length two strings are identical.

Example

C Compiler
#include <stdio.h> #include <string.h> int main() { char str1[] = "wikimass is awesome"; char str2[] = "wikipedia is great"; long len = strspn(str1, str2); printf("Length of initial segment matching: %ld", len); return 0; }

Syntax

size_t strspn(const char *str1, const char *str2)

Parameter Values

ValueTypeExplanation
str1 Required Specifies the string 1
str2 Required Specifies the string 2

Return Value

ValueExplanation
Number Returns the position of the string from where the source array does not matches with the target one.

Share this Page

Meet the Author