Question: Write a c++ function named StringGame that replaces a substring with another substring. The function should accept three C-string arguments called string1, string2, string3. Note
Write a c++ function named StringGame that replaces a substring with another substring. The function should accept three C-string arguments called string1, string2, string3. Note again that we are using C-Strings in this program, not jum. It should search string1 for an occurrence of string2. When it finds an occurrence of string2, it should replace it with string3. If string2 appears more than once in string1, only the first occurrence should be replaced.
Test the program either with a loop or by running it twice and turn in output for the following data sets:
String1 the dog jumped over the fence
String2 the
String3 that
Create a string called resultString and build it by:
- Putting in the part before the replacement (if there is any)
- Putting in the replacement
- Putting in the part after the replacement (if there is any).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
