Uni problem (string.replace)

I was given the task to write a small program that uses the .replace function. I have to replace bill (from the sentece "bill and ben the flower pot men ") with marmeduke! also it cant require the user to touch anything.

i looked at the c++ pages for .replace function but its not in terms i understand. Could someone please take 5 mins and finish the program and leave comments explaining what does what. thank you:)
what i have so far.
---------------------------------|
#include <iostream>
#include <string>

using namespace std;

int main()
{

string base_sen = "bill and ben the flower pot men";
string replace = "Marmeduke";


system("pause");
return 0;
}
1
2
3
4
5
6
7
8
9
10
string base_sen = "bill and ben the flower pot men";
string source = "bill";
string replace = "Marmeduke";

cout << base_sen << endl;

string::size_type n = base_sen.find( source );
if ( n != std::string::npos ) base_sen.replace( n, source.size(), replace );

cout << base_sen << endl;
Topic archived. No new replies allowed.