title: bug in printing phrases of a sentence c++
body: <pre><code>vector &lt;string&gt; oneWordPhrase;
  vector &lt;string&gt; twoWordPhrase;
  vector &lt;string&gt; threeWordPhrase;    
  
  string str="hello my is bob oh hey jay oh";
  
  vector&lt;string&gt;::iterator it1;
  vector&lt;string&gt;::iterator it2;
  </code></pre>
  
  <p>I broke the sentence up in str into individual words and stored them into vectors called oneWordPhrase. So, the vector will have a size of 7</p>
  
  <pre><code>for(it1=oneWordPhrase.begin(); it1!=oneWordPhrase.end(); it1++)
  {
      if(it1+1 == oneWordPhrase.end())
          break;  /* if we reach the last element of the vector
                       get out of loop because we reached the end */
      twoWordPhrase.push_back(*it1 + ' ' + *(it1+1));
  }//gets each 2 consecutive words in the sentence
  
  cout&lt;&lt;"two word---------------\n";
  for(int i=0; i&lt;twoWordPhrase.size(); i++)
      cout&lt;&lt;twoWordPhrase[i]&lt;&lt;endl;
  </code></pre>
  
  <p>This produces the correct output:</p>
  
  <p>hello my</p>
  
  <p>my is</p>
  
  <p>is bob</p>
  
  <p>bob oh</p>
  
  <p>oh hey</p>
  
  <p>hey jay</p>
  
  <p>jay oh</p>
  
  <pre><code>for(int i=0; i&lt;twoWordPhrase.size()-1; i++)
  {   
      it1=twoWordPhrase.begin()+i;
      it2=oneWordPhrase.begin()+i+2;
      if(it1==twoWordPhrase.end()-1)
          break; //signal break but doesnt work
      threeWordPhrase.push_back(*it1 + ' ' + *it2);
  }
  cout&lt;&lt;"three words-----------\n";
  for(int i=0; i&lt;threeWordPhrase; i++)
      cout&lt;&lt;threeWordPhrase[i]&lt;&lt;endl;
  </code></pre>
  
  <p>This produces the correct output but there are two lines of white space at the end</p>
  
  <p>hello my is</p>
  
  <p>my is bob</p>
  
  <p>is bob oh</p>
  
  <p>bob oh hey</p>
  
  <p>oh hey jay</p>
  
  <p>//whitespace</p>
  
  <p>//whitespace</p>
  
  <p>I also tried to use the iterator in my for loop to signal the break but it didn't work. Why is it printing two extra lines of white space?</p>