logo CodeStepByStep logo


Language/Type: C arrays strings
Author: Cynthia Lee (on 2016/10/02)

Write a function named countMatches 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 countMatches("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.

Type your C solution code here:

This is a function problem. Write a C function as described. Do not write a complete program; just the function(s) above.

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.

© Marty Stepp, all rights reserved.