CSM217: C for Computer Scientists

Lecture 3: Exercises

Exercise 1

Write the function squeeze(char s1[], char s2[]) that deletes each character in s1 that matches any character in the string s2.

The solution is here, or else you can mail me.

Exercise 2

Write the function any(char s1[], char s2[]) which returns the first location in the string s1 where any character from the string s2 occurs, or -1 if s1 contains no characters from s2. For example, any("hello", "eh") will return 0 (because 'h' occurs in location 0).

The solution is here, or else you can mail me.