Submission Deadline: 17-June-2003 till 6:00pm
Submission Folder: subStrRep16_6
Assignment:
Write a function (with the name "SubStrRep") that takes 3 dynamically allocated strings and replaces every occurance of string2 with string3 in string1. All the 3 strings can be of any size. string2 can be longer than string3 and vice versa. You should not waste any memory.
e.g.This is just an example. Your function should be able to handle any input in all 3 strings.
char *string1 = new char[92];
char *string2 = new char[18];
char *string3 = new char[15];
strcpy (string1, "Our university has the best university campus than any other university campus in the city.");
strcpy (string2, "university campus");
strcpy (string3, "college campus");
function call: SubStrRep(string1, string2, string3);
You have to decide the function prototype for your self, but the function call written above should be valid.
After the function is called, string1 should be changed so that it contains the contents:
string1 = "Our university has the best college campus than any other college campus in the city."