2. Implement the standard C function size_t strspn(const char *s, const char *accept) that returns how many characters at the start of s belong to accept, without other characters in between. For instance, strspn("abracadabra", "cba") returns 2: the first two characters belong to "cba", the third one no longer does.
3. Write a function int belongsto(char c, const char *cset) that checks whether c belongs to the set of characters represented by string cset . In latter, a character range c1-c2 represents all characters with values at least c1 and at most c2. Other individual characters represent themselves. Thus, "0-9A-z,a-f" represents digits, upperchase letters, the comma, and lowercase letters up to f. A dash (minus) as first or last character of the string represents itself (since it is not separating the endpoints of a range). If two ranges share an endpoint: c1-c2-c3, they represent the union of the ranges c1-c2 and c2-c3.
Marius Minea Last modified: Sun Nov 3 19:00:00 EEST 2013