K&R Exercises

Exercise 2-5: First occurrence of any character

Write the function any(s1,s2), which returns the first location in a string s1 where any character from the string s2 occurs, or -1 if s1 contains no characters from s2. (The standard library function strpbrk does the same job but returns a pointer to the location.)

The input is pairs of lines: s1, then s2, without their newlines. For each pair, print any(s1,s2) on a line of its own.

Test Cases

· space→ tab↵ newline

Submissions

No submissions yet