title: Simple C++ Substring Issue
body: <p>The program does not properly find the substrings of each section of the name "John Fitzgerald Kennedy", and cannot output each name on a separate line.  The program outputs a out of range exception and does not even show the second name, only the first.  How would I ouput each name on each separate line?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int main()
  {
  
  string fullName="",
          firstName="",
          middleName="",
          lastName="";
  
  cout&lt;&lt;"Enter your full name: ";
  cin&gt;&gt;fullName;
  
  firstName=fullName.substr(0,4);
  middleName=fullName.substr(4,14);
  lastName=fullName.substr(14,19);
  
  cout&lt;&lt;firstName&lt;&lt;endl;
  cout&lt;&lt;middleName&lt;&lt;endl;
  cout&lt;&lt;lastName;
  
  cin.get();
  cin.get();
  
  return 0;
  }
  </code></pre>