can someone help me regarding my program? i am tasked to create a program called string censoring. it asks for two strings then it removes the characters in the first string which are similar to those in the second.
Ex:
1st string= new york yankees
2nd string= absolutely
result= nw rk nk
and another thing, it has to be case sensitive..haaayy...
here's the code that i've done but it doesn't work correctly..can someone help me out?
#include <iostream>
#include <string>
#include <conio.h>
using namespace std;
int main(){
cout << "Input string" << "\n\n" << endl;
string firstStr;
cin >> firstStr;
cout << "Input second string." << "\n\n" << endl;
string secondStr;
cin >> secondStr;
string newStr;
int j = secondStr.length();
for (int k = 0; k != j; k++){
int i = firstStr.find(secondStr[k]);
int gPos = i;
if (gPos != string::npos){
while (gPos != string::npos){
newStr = firstStr.substr(0,i);
newStr += firstStr.substr (i + j);
}
}else break;
}
cout <<"''"<< firstStr <<"''"<< " with ''" << secondStr << "'' removed becomes ''"
<< newStr << "''" << endl;
getch();
}
help me out please..