I need to implement this function:

Code:
int StrSpn(char *str, int ch);
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.

This is what it is supposed to do:

Code:
char *teststr = "self-explanatory program";
char *teststr2 = "123 is the number";
int count;

/* count number of initial lowercase letters */
count = StrSpn(teststr, "abcdefghijklmnopqrstuvwxyz");
printf("%d\n", count);
And the answer should be 4.



Using only C and stdio.h