Replacing a string in a string with another string
I have this problem. I have a global string, and then a function called replace that has two strings, say str1 and str2, as parameters. I am supposed to replace all the occurrences of str1 in the global string with str2. And I am told not to use any functions from external libraries (I don't know what this means but I think it means I shouldn't use the class string or something). I have thought about it for a long time but couldn't find a way out of it. I have thought of putting the global string in a loop, and replacing all the occurrences of str1 characters in it with str2 characters but this only allows replacement of characters, and I need to replace an entire string.
So our new string, after we are done with replacing it becomes: