C Programming
Computer Programming

C program to searches specified string and returns the number of the characters matched using strspn() function



Write a program in C to searches specified string in the given string and returns the number of the characters that are matched in the given string using strspn() function

\* C program to searches specified string and returns the number of the characters matched using strspn() function *\

# include < stdio.h >
# include < string.h >
int   main( )
{

char str1[100], str2[100] ;
int len ;
printf ("\n Enter the first string : ") ;
scanf("%s", str1 ) ;
printf ("\n Enter the second string : " ) ;
scanf("%s", str2 ) ;
len = strspn(str1, str2 ) ;
printf("\n Number of matched characters : %d\n", len ) ;
return 0 ;

}

Output of Program :

Output of C program to searches specified string and returns the number of the characters matched using strspn() function