Replace char in string?? c++?
I am having trouble learning(distant learning) how to teach myself the algorithm to find and replace chars within a string. The program prompts the user to enter a string of chars, then the user is prompted again to enter the chars wished to be removed. I am trying to basically search and destroy and not making it past the search part. I am basically confusing myself. Anyway, I know that I am working with cstring and need to copy and move the char/chars to be removed but cannot figure out how. I am not asking for anyone to finish it so theres nothing left--just help me with the algorithm. I am new to c++, so excuse my lack of tags and messy code. I am only giving my code for the purpose of knowing what I am attempting to do, not to complete it. I have a few more things to add once I get this algorithm down.
# include <iostream>
# include <cstring>
using namespace std;
int main()
{
char str1[41];
char str2[21];
char ans;
int i;
cout<<"Please enter a string (40 characters max)-->";
cin.getline(str1, 40);
cout<<"Please enter the characters to be removed(20 characters max) -->";
cin.getline(str2, 20);
for(i=0;i!=str1[i];i++)
{
cout<<"First string with characters removed-->";
}
cout<<"Would you like to do another(y or n)?";
cin>>ans;
if(ans!='y'||ans!='Y')
More Related Questions and Answers ...
The information post by website user , we not guarantee correctness.
Dental Treatment Skin Whitening Skin Problems Skin Rashes Shoes
