Reusing std::cin after EOF
<p>The code below is for storing a group of words in a <code>std::vector</code> and to count how many times a particular word given by the user appears in the vector by comparing it to all the words stored in the vector.</p>

<p>The console does not prompt me for input at the second <code>std::cin &gt;&gt;</code> in the program below.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;ios&gt;
#include &lt;iomanip&gt;
#include &lt;vector&gt;
#include &lt;algorithm&gt;
using namespace std;

int main(int argc, const char * argv[])
{
   cout&lt;&lt;"enter your words followed ny EOF"&lt;&lt;endl;
   vector&lt;string&gt; words;
   string x;
   typedef vector&lt;string&gt;::size_type vec_size;
   vec_size size;
   while (cin&gt;&gt;x) 
   {
     words.push_back(x);
   }
   size=words.size();
   cin.clear();

   //now compare
   cout&lt;&lt;"enter your word:"&lt;&lt;endl;
   string my_word;
   int count=0;

   cin&gt;&gt;my_word;              //didn't get any prompt in the console for this 'cin' 
   for (vec_size i=0; i&lt;size; ++i) 
   {
      my_word==words[i]?(++count):(count=count);
   }
   cout&lt;&lt;"Your word appeared "&lt;&lt;count&lt;&lt;" times"&lt;&lt;endl;
   return 0;

}
</code></pre>

<p>The final output I get is "Your word appeared 0 times".
What is the problem with the code. Any help would be great.</p>
