Hi I am trying to write a little program that will replace a charter in a string, for example if there is a “5”, replace it with a “?” I have been playing around with the “replace” function but cant get it to work.
I have read every page that i cam find on google, and i am still lost... Please help!Code:char rep[] = {5};
int i, pos;
string sen;
cout << "Please enter a sentence ";
getline (cin, sen);
for (i = 0; i < sizeof(rep); i++)
{
while ((pos = sen.find(repl[i])) != string::npos)
{
sen[pos] = replace // This is where I am lost?
}
}
cout << sen;