I need to implement this function:
The function StrSpn counts the number of consecutive characters in the first argument str (which is null-terminated) that consist entirely of character specified in the second argument string set (which is also null-terminated). Counting begins with the first character in the string.
int StrSpn(char *str, int ch);
This is what it is supposed to do:
And the answer should be 4.
char *teststr = "self-explanatory program";
char *teststr2 = "123 is the number";
/* count number of initial lowercase letters */
count = StrSpn(teststr, "abcdefghijklmnopqrstuvwxyz");
Using only C and stdio.h