title: Splitting sentences and placing in vector
body: <p>I was given a code from my professor that takes multiple lines of input. I am currently changing the code for our current assignment and I came across an issue. The code is meant to take strings of input and separate them into sentences from periods and put those strings into a vector. </p>
  
  <pre><code>vector&lt;string&gt; words;
  string getInput() {
    string s = ""; // string to return
    bool cont = true; // loop control.. continue is true
    while (cont){     // while continue
      string l;       // string to hold a line
      cin &gt;&gt; l;       // get line
      char lastChar = l.at(l.size()-1);
      if(lastChar=='.') {
          l = l.substr(0, l.size()-1);
          if(l.size()&gt;0){
              words.push_back(s);
              s = "";
          }
      }
      if (lastChar==';') {     // use ';' to stop input
          l = l.substr(0, l.size()-1);
          if (l.size()&gt;0) 
            s = s + " " + l;
          cont = false; // set loop control to stop
        }
  
      else
        s = s + " " + l; // add line to string to return
                         // add a blank space to prevent
                         //   making a new word from last
                         //   word in string and first word
                         //   in line
    }
    return s;
  }
  
  int main()
  {
    cout &lt;&lt; "Input something: ";
    string s = getInput();
    cout &lt;&lt; "Your input: " &lt;&lt; s &lt;&lt; "\n" &lt;&lt; endl;
    for(int i=0; i&lt;words.size(); i++){
      cout &lt;&lt; words[i] &lt;&lt; "\n";
    }
  }
  </code></pre>
  
  <p>The code puts strings into a vector but takes the last word of the sentence and attaches it to the next string and I cannot seem to understand why. </p>