title: Input values into a vector until the end of input?
body: <p>So I want the user to input something like this:</p>
  
  <pre><code>0 15 72 34 92 8
  </code></pre>
  
  <p>and I want to fill a vector of integers with these numbers.</p>
  
  <p>Here is what I have:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  int main()
  {
      vector&lt;int&gt; V;
      cout &lt;&lt; "Please enter the numbers separated by \n";
      cout &lt;&lt; "spaces, then press the \"Enter\" key.\n\n";
  
      int temp;
      while (cin &gt;&gt; temp)
      {
          V.push_back(temp);
      }
  // The programs gets to this point and continuously asks for input
  
  
  
  // Print the vector
      cout &lt;&lt; "The vector contains [ ";
      for(int i = 0; i &lt; V.size(); i++)
          cout &lt;&lt; V.at(i) &lt;&lt; " ";
      cout &lt;&lt; "], ";
  
  }
  </code></pre>