strspn
Computes the length of the initial segment of a string consisting of characters from a given set
#include <string.h> size_t strspn ( const char *str, const char *charset);
The strspn function returns the offset from the beginning of the string str where the characters in charset have ended.
The strspn function computes the length of the initial segment of the string pointed to by str, which consists of characters from the string pointed to by charset. The terminating NULL character is not considered to be part of charset.
#include <string.h> #include <stdio.h> main () { printf ("%d\n", strspn ("out to lunch", "aeiou") ); printf ("%d\n", strspn ("out to lunch", "xyz") ); }
produces the following:
2 0