Checking for input "0" (zero) with cin
<p>I'm trying to have a program loop, accepting input and producing output until the user enters "0" as the input.</p>

<p>The problem is, my program accepts two values for input, like this:</p>

<pre><code>cin &gt;&gt; amount &gt;&gt; currency;
</code></pre>

<p>So, I tried to have a while statement like this:</p>

<pre><code>while (amount != 0 &amp;&amp; currency != "") {
    cin &gt;&gt; amount &gt;&gt; currency;
    cout &lt;&lt; "You entered " &lt;&lt; amount &lt;&lt; " " &lt;&lt; currency &lt;&lt; "\n";
}
</code></pre>

<p>However, the while statement always executes, even if I enter <code>0</code> as input.</p>

<p>How do I write the program such that it accepts two values as input except when the user enters 0, in which case it terminates?</p>
