Question: C++, don't pass chapter 6, functions for the code. **6.43 (Check substrings) Write the following function to check whether string sl is a substring of
C++, don't pass chapter 6, functions for the code.
**6.43 (Check substrings) Write the following function to check whether string sl 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: Enter the first string: welcome tr Enter the second string: We welcome you!Ente indexOf("welcome", "We welcome you!") is 3 Enter the first string: welcome -Enter Enter the second string: We invite you! Enter indexof("welcome", "We invite you!") is -1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
