strspn
Span a string
Description
The strspn function spans the initial part of the null-terminated string \c s as long as the characters from \c s occur in string \c charset.Example:
Example - Span a string
Workings
#include <stdio.h> #include <string.h> int main() { char s[20] = "0123456abcde", t[11] = "0123456789"; printf("The position of the first non-digit in s is: %d.\n", strspn(s, t)); return 0; }
Solution
Output:
The position of the first non-digit in s is: 7.