(Check substrings) Rewrite the indexOf function in Programming Exercise to check whether C-string s1 is a substring of C-string s2. The function returns the first index in s2 if there is a match. Otherwise, return −1.
int indexOf(const char s1[], const char s2[])
Write a test program that reads two C-strings and checks whether the first string is a substring of the second string. The sample run is the same as in Programming Exercise.
Programming Exercise (Check substrings) Write the following function to check whether string s1 is a substring of string s2. The function returns the first index in s2 if there is a match. Otherwise, return −1.
int indexOf(const string& s1, const string& s2)
Write a test program that reads two strings and checks whether the first string is a substring of the second string. Here is a sample run of the program:


We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.