logo CodeStepByStep logo

count_matches

Language/Type: C arrays string
Related Links:
Author: Cynthia Lee (on 2018/02/03)

Write a function named count_matches that accepts a string to match (as char *), an array of strings (as char*[]), and the size of the array, and returns the number of strings in the array that have contain the string to match as a substring. For example, if strs is defined as char * strs[] = {"rainbow", "sunshine", "bowtie", "cow", "ow", "happy"};, then the call count_matches("ow", strs, 6) returns 4. The empty string is a substring of any string. You may assume that the size argument correctly represents the size of the array, and that the match string is not NULL.

Function: Write a C function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.