title: Using vectors to bleep some predefined strings
body: <p>So i'm currently doing the exercices in my programming book "Programming: Principles and practice using c++" from Bjarne Stroustrup and i'm curently stuck at one exercice. Basically, the exercice is to write a program that bleeps out words it doesn't like. The way it works is that the user inputs a string and the program repeats the word. If the word the user enters is part of the dislike vector, the word is replaced by "Bleep". (I don't know if I explained this right, but it shouldn't be to complicated to understand).</p>
  
  <p>This is my version of the program:</p>
  
  <pre><code>int main()
  {
      string dislike = "Potato";
      string words = " ";
  
      cout &lt;&lt; "Please enter some words: " &lt;&lt; endl;
      while(cin&gt;&gt;words)
      {
          if(words==dislike)
          {
              cout &lt;&lt; "Bleep!" &lt;&lt; endl;
          }
  
          else
          {
              cout &lt;&lt; words &lt;&lt; endl;
          }
      }
      system("pause");
      return 0;
  }
  </code></pre>
  
  <p>As you can see, this version isn't using vectors (and it should, because the exercice is right after the explanation of vectors in the chapter). So my question is, how can I implement a vector with many "dislike" words in it like this:</p>
  
  <pre><code>vector&lt;string&gt;dislike;
  dislike.push_back("Potatoes");
  dislike.push_back("Peanuts");
  dislike.push_back("Coconut");
  </code></pre>
  
  <p>and make it so it works like my other version without vectors (repeats words, but bleeps the dislike words). I can't seem to understand how to navigate in a vector so that it only bleeps the "dislike" words.</p>
  
  <p>If someone could give me a hand and explain to me how it works (please do not just give me the answer) it would be very appreciated.</p>
  
  <p>Thank you for your time and help, learning c++ alone isn't always simple, and I thank this website for making my learning curve a bit easier.</p>
  
  <p>bobicool</p>