VECTOR Fun - The Ultimate Extra Credit

SETUP: Create a new folder in your vector folder called "vectorBannedWords" --> give it that same name for the console application.

TASK: You are to create a new program that takes a string and removes words from it that appear in a vector.

PROCESS:

Your program's main method should:

  • Call a helper method populating the vector of banned words (Ask how many words to ban, then use a loop to get them from the user)
  • Call a helper method asking the user to provide (at least a sentence or two) text from which to remove the banned words
  • Call a helper method that removes all the banned words from the text
  • Display the new text (without the banned words)
  • You will need at the top of your program:

    #include <vector>
    #include <string>

    Your task is to take a long string object and remove all the words from it that appear in the vector bannedWords

    Use string.h [list of capabilities] --> You will need to use (at least) erase(), find(), length()

    Using Vectors [list of capabilities]

    You will need to use cin.getline(text, 256); to get a full text

    /*
        AUTHOR: YOUR NAME
        DATE: ______
    
        DESCRIPTION: This program removes all banned words from a given text.
    */
    
    #include <iostream>
    #include <vector>
    #include <string>
    using namespace std;
    
    void getBannedWords (vector<string>&);
    string getText ();
    void removeBadWords(vector<string>&, string&);
    void display (string);
    
    
    int main()
    {
    cout << "Welcome to the bad word removal program." << endl;
    string text = getText();
    cout << " You entered: " << text << endl;;
    vector<string> bannedWords;
    getBannedWords(bannedWords);
    removeBadWords(bannedWords, text);
    cout << endl << "Text after removals: ";
    cout << text;
    return 0;
    }