Question: C++ complete and working program Q2. Programming Exercise 6.43 (10 marks) (Check substrings, const reference parameters, loop, char array processing) Write the following function to
C++ complete and working program

Q2. Programming Exercise 6.43 (10 marks) (Check substrings, const reference parameters, loop, char array processing) 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 are two sample runs of the program: Enter the first string: welcome [enter] Enter the second string: We welcome you! [enter] 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
