Problem

(Check substrings) Rewrite the indexOf function in Programming Exercise to check whether C...

(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:

Step-by-Step Solution

Request Professional Solution

Request Solution!

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.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT