title: Make user give input until they enter X
body: <p>I'm writing a program in C++ that takes integers from the user until they press "x" to stop.</p>
  
  <p>Then the program will print the number of positives, negatives and zeros.</p>
  
  <p>But whenever the user inputs "x", the program goes into an infinite loop.</p>
  
  <p>I tried removing the "ZEROS" part and just made counters for positives and negatives and it worked good. But I want to count the zeros.</p>
  
  <p>I need to let the user enter numbers including 0 until they enter character x.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main() {
      int input, neg = 0, pos = 0, zer = 0;
      char z;
  
      do {
          cout &lt;&lt; "Input another positive/negative number or 'x' to stop\n";
          cin &gt;&gt; input;
          cin.ignore();
  
          if (input &gt; 0){
              pos++;
          } else if (input == 0){
              zer++;
          } else if(input &lt; 0){
              neg++;
          }
      } while (z!='x');
  
      cout &lt;&lt; "You entered " &lt;&lt; pos &lt;&lt; " positive numbers.\n";
      cout &lt;&lt; "You entered " &lt;&lt; neg &lt;&lt; " negative numbers.\n";
      cout &lt;&lt; "You entered " &lt;&lt; zer &lt;&lt; "Zeros.";
  
      return 0;
  }
  </code></pre>