C library function strcspn()




C library function strcspn()

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

	int size;

	// initializing strings
	char str1[] = "tutorialsroot";
	char str2[] = "kfc";

	// using strcspn() to calculate initial chars
	// before 1st matching chars.
	// returns 3
	size = strcspn(str1, str2);

	printf("The unmatched characters before first matched character : %d\n", size);
}

Output

The unmatched characters before first matched character : 3