Assignment 8
Write and thoroughly test the following two functions that implement search-and-replace capability for a string. Your main program should allow the user to enter a string for processing, a string to search for, and a string to replace it with.
apstring ReplaceFirst(apstring str, apstring pattern, apstring repl);
// Precondition: pattern is a non-zero length apstring
// Postcondition: returns a copy of str in which the first occurrence
// of pattern has been replaced with string repl
apstring ReplaceAll(apstring str, apstring pattern, apstring repl);
// Precondition: pattern is a non-zero length apstring
// Postcondition: returns a copy of str in which all occurrences
// of pattern have been replaced with string repl; however, if
// pattern occurs in repl, returns the string without change
Remember to test all 'special' conditions; for instance, if str or repl are empty, or if pattern occurs in repl.
Turn in a printed copy of your program and sample output, or a floppy disk containing the program.