title: C++ stop do while loop once condition is met
body: <pre><code>do {
     cout &lt;&lt; "Quantity  : ";
     cin &gt;&gt; sale-&gt;quantity;
     cout &lt;&lt; "Unit Price: ";
     cin &gt;&gt; sale-&gt;unitPrice;
     cout &lt;&lt; "Taxable   : ";
     cin &gt;&gt; sale-&gt;taxStatus;
  } while (sale-&gt;quantity != 0); 
  </code></pre>
  
  <p>When I enter <code>0</code> for <code>quantity</code>, it still asks me for <code>unitPrice</code> and <code>taxStatus</code>, and then it terminates. How could I get my loop to terminate as soon as <code>quantity</code> entered is <code>0</code>?</p>
  
  <p>edit</p>
  
  <pre><code>&gt; echo "" | a.out 
  Sale Records 
  =============
  Quantity  : Unit Price: Taxable   : Quantity  : Unit Price: Taxable   : Quantity  : Unit Price: Taxable   : Quantity  : Unit Price: Taxable   : Quantity  : Unit Price: Taxable   : Quantity  : Unit Price: Taxable   : Quantity  : Unit Price: Taxable   : Quantity  : Unit Price: Taxable   : Quantity  : Unit Price: Taxable   : Quantity  : Unit Price: Taxable   : &gt;
  </code></pre>