I have been having a bit of trouble with my find and replace function I can get it to replace all characters but I only want it to change the characters that match the banned words.
Here is my code so far
class getTextData
{
private:
string currentWord;
vector<string> bannedWords;
vector<string> textWords;
int bannedWordCount;
int numWords;
char ch;
int index[3];
ifstream inFile ();
public:
void GetBannedList(string fileName);
void GetWordAmount(string fileName);
void GetDocumentWords(string fileName);
void FindBannedWords();
void ReplaceWords(string fileOutput);
};
for(int i = 0; i <= numWords; i++)
{
for(int j = 0; j < bannedWordCount; j++)
{
if(string::npos != textWords[i].find(bannedWords[j]))
{
textWords[i] = "***";
}
}
}
This just replaces with a fixed number of * but I want it to replace the characters it finds with a * not the whole word.
Thanks In Advance
Try this: