Pointer to the null-terminated string to be scanned.
2nd Parameter Type : const char *
Pointer to read-only string
2nd Parameter
Pointer to the null-terminated string containing the set of characters to match in `str1`.
Read more about parameters of strspn in parameters section
The strspnfunction in C language Calculates the length of the initial segment of the string which consists only of characters found in a specified string.
The strspn function calculates the length of the initial segment of str1 which consists entirely of characters in str2. In other words, it returns the index of the first character in str1 that does not appear in str2.
The strspnfunction takes 2
parameters:
•
const char * `str1`: Pointer to the null-terminated string to be scanned.
•
const char * `str2`: Pointer to the null-terminated string containing the set of characters to match in `str1`.
Calculates the length of the initial segment of `str1` consisting entirely of characters found in `str2`. Returns the number of characters in this segment as a `size_t`.
The strspn function return value :
Returns the number of characters in the initial segment of str1 which consist only of characters from str2
Output
This example demonstrates basic usage of strspn to find the length of the initial segment of digits in a string.