std::string vect = "one two nyes four nyes five nyes six";
std::string ban = "nyes";
int match = 0;
for (size_t i=0;i<vect.size();i++){
for (size_t j=0;j<ban.size();j++){
if (vect[i+j]==ban[j]) {
match++;
}
if (match = ban.size()) {
for (size_t y=i;y<i+ban.size();y++) {
vect[y] = '*';
}
}
}
}
std::cout << vect;
}
I just started learning, and in an exercise that wants me to censor specific words in a string, this is what I came up with. I was able to compile and execute in VS, but the result was an error? https://www.upsers.biz/
What exactly does 'specific words in a string' mean?
Can the word be a fragment (ie. part of another word)? For example, does 'placate' contain the word 'cat'?
Is the search for words case insensitive? For example, would 'The' match the word 'the'?