My homework problem is the following :Write a program that accepts a string from the user and then replaces all occurrences of
the letter e with the letter x. I got the following code below that can recognize to find characters and where they are at but I don't know how to get it to replace and 'e' with a 'x'.
#include <iostream>
#include <string>
using namespace std;
int main()
{
string y;
char x;
size_t found=0;
size_t ind=0;
cout<<"Please enter a string: "<<endl;
cin>>y;
cout<<"Please enter a character: "<<endl;
cin>>x;
while(found!=-1)
{
found=y.find(x,ind);
ind=found+1;
if(found==-1)
{break;}
cout<<"Character is found at "<<(int) found<<"\n";}
cin.get();
cin.get();
return 0;
}