strspn() and strcspn() counts how many chars of a set are or aren't in the original string since it's beginning:
Code:
size_t sz = strspn( "#!#abc", "#!" ); // will return 3 because '#' and '!' are the 3 first chars.
strcspn() is complementary to this span count. It will count how many chars from the set aren't in the original string, since its beginning:
Code:
size_t sz = strcspn( "abc#!#", "#!" ); // will return 3 because 'a', 'b' and 'c' aren't '#' or '!'
That's it. If you use:
Code:
size_t sz = strspn ( "abc#", "#!" ); // will return 0, because 'a' isn't '#' or '!'.