3.10. strspn
size_t strspn( const char *s1, const char *s2);strspn returns the length of the prefix of s1 consisting of characters in s2.
In other words, strspn counts how many of the leading characters of s1 are from the set of characters specified in s2
and stops when it finds a character which is not in s2.
Say, for example, that you want to strip off the leading blanks and tabs on lines from stdin:
int n; while( fgets( line, BUFSIZ, stdin) != NULL) /* read one line */ { n = strspn( line, " \t"); fputs( &line[n], stdout); }strspn can be written using strchr:
size_t n = 0; while( s1[n] != '\0' && strchr( s2, s1[n]) != NULL) ++n; return n;