Home / Expert Answers / Computer Science / im-trying-to-make-a-simple-c-censorship-program-but-the-input-is-just-printed-out-without-the-aste-pa871

(Solved): Im trying to make a simple C++ censorship program but the input is just printed out without the aste ...



Im trying to make a simple C++ censorship program but the input is just printed out without the asterisks. Solve and explain please.

 

#include <iostream>
#include <string>
using namespace std;

void cleanLanguage(string &phrase) {
    
    //while loop checks if the word is present by checking for an index
    while (phrase.find("damn") > -1)
        phrase.replace(phrase.find("damn"), 4, "****");

    while (phrase.find("hell") > -1)
        phrase.replace(phrase.find("hell"), 4, "****");

    cout << phrase << endl;
}

int main() {
    
    string phrase;

    cout << "Enter a phrase to be censored: ";
    getline(cin, phrase);
    cleanLanguage(phrase);

    return 0;
}



We have an Answer from Expert

View Expert Answer

Expert Answer


Solution: Given problem is related to the C++ programming, As per given question a errored C++ code has been provided, Below is the corrected C++ code
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe