Question: This is a problem from a C++ Data Structures class. Please clearly explain your answer. (Problem 18 Number 153) Write a function named replace that
This is a problem from a C++ Data Structures class. Please clearly explain your answer.
(Problem 18 Number 153)
Write a function named replace that takes three string arguments:
void replace(string base, string pattern, string replacement);
The function should replace all instances of the pattern in the base string with the replacement string. Note that the replacement string may not be the same length as the pattern string. Instances of the pattern in the replacement should not be replaced. For example, if the base string is "all in good time," the pattern "good," and the replacement "very good," your procedure should avoid going into an infinite loop.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
