#include <iostream>
#include <string>
using namespace std;
int main()
{
    cout << "Enter a string:\n";
    string array_1;
    getline(cin, array_1);

    cout << "Enter a string you want to find:\n";
    string ch;
    getline(cin, ch);

    cout << "Enter a string you wish to replace " << ch << " with:\n";
    string ch2;
    cin >> ch2;

    for(size_t pos = array_1.find(ch); pos != std::string::npos;
               pos = array_1.find(ch, pos))
    {
        array_1.replace(pos, ch.size(), ch2);
        pos += ch2.size();
    }

    cout << "Here is the new string: " << array_1 << '\n';
}
