CS 13A

Prof. Sturm                  

                                    Homework #5 – strings

 

Write function findSubStr(char str[], char subStr[]).  Function findSubStr returns the position of (the first occurrence of) subStr within str.  If subStr is not there, then the value -1 is returned.

 

Write function deleteSubStr(char str[], char subStr[]).  Function deleteSubStr finds the position of subStr within str, by calling function findSubStr.  It then deletes subStr from str. (Hint: Use a string called temp to help with the deletion.)

 

Write a main procedure that calls deleteSubStr to delete the first “sea” from “she sells sea shell by the sea shore”.