Input terminal problems and map
<p>I am using map to count the occurence of words. Here is the code.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;map&gt;
#include &lt;string&gt;
using namespace std;
int main() {
    map&lt;string,int&gt;wordcount;
    string s;

    while (cin&gt;&gt; s &amp;&amp; s!="red")
        ++wordcount[s];

    while (cin&gt;&gt;s &amp;&amp;  s!="red")

    cout &lt;&lt; s &lt;&lt; "   " &lt;&lt; wordcount[s] &lt;&lt; endl;
    return 0;
}
</code></pre>

<p>I start the program, type words and at the last line enter the word "red", but it does not do anything. Then I type "red" the second time and it outputs:</p>

<blockquote>
  <p>press any key to continue</p>
</blockquote>

<p>what is wrong?</p>
