title: Adding values to a vector until the user inputs 0 in C++?
body: <p>How do I structure my while loop so that it will keep accepting int values until the user enter 0?  </p>
  
  <p>I have </p>
  
  <pre><code>while(cin &gt;&gt; integers &amp;&amp; integers != 0){
      numbers.push_back(integers);
      if(integers == 0){
          break;
      }
  }
  </code></pre>
  
  <p>but it keeps crashing on me.  </p>
  
  <p>Edit: </p>
  
  <pre><code>int integers;
      int fox;
      vector&lt;int&gt; numbers;
      cout &lt;&lt; "Please enter in integers (0 to stop): ";
      while(cin &gt;&gt; integers){
          numbers.push_back(integers);
          if(integers == 0){
              break;
          }
      }
      int y = numbers.size();
      for(int i = 0; i &lt; y; y++){
          cout &lt;&lt; numbers.at(y) &lt;&lt; " ";
      }
  </code></pre>