title: C++ cin >> not starting again
body: <p>Ok, so I am doing an exercise for a C++ programming book, and it asks me to make a program that I enter names and scores next to those names, and they are both saved in vectors. Then, after I am finished entering those, it will prompt me to enter a name, then it will find the corresponding score to that name. e.x. I type in "John" it returns 5 if that's what I put John's score as.</p>
  
  <p>The problem I am having, is after the user is done entering the names and scores, and my program prompts the user to enter in a name (to find the corresponding score), the code just skips over the <code>cin</code> command and moves on, making my program not work. I will post the full program, then the part I need help with:</p>
  
  <pre><code>#include "std_lib_facilities.h"
  
  int main()
  {
  vector&lt;string&gt;names;
  vector&lt;int&gt;scores;
  string name = "";
  int score;
  while(cin &gt;&gt; name &amp;&amp;  cin &gt;&gt; score)
  {
          for(int i = 0; i &lt; names.size(); ++i) // checks all previous words
          {
              if(name == names[i]) // if the name is used twice, exit
              {
                  cout &lt;&lt; "Error. Terminating...\n";
                  exit(4);
              }
              else;
          }
  
          names.push_back(name);
          scores.push_back(score);
  }
  
  cout &lt;&lt; "Enter a name, which I will find the score for. \n";
  string locateName;
  while(cin &gt;&gt; locateName) // i think the program won't accept the locateName
  {
  
      for(int i = 0; i &lt; names.size(); ++i)
      {
          if(locateName == names[i])
          {
              cout &lt;&lt; names[i] &lt;&lt; "'s score is " &lt;&lt; scores[i] &lt;&lt; '\n';
          }
          else { cout &lt;&lt; "Name not found. \n"; }
      }
  
  }
  return 0;
  }
  </code></pre>
  
  <p>Here is the part that is not working:</p>
  
  <pre><code>cout &lt;&lt; "Enter a name, which I will find the score for. \n";
  string locateName;
  while(cin &gt;&gt; locateName)
  {
  
      for(int i = 0; i &lt; names.size(); ++i)
      {
          if(locateName == names[i])
          {
              cout &lt;&lt; names[i] &lt;&lt; "'s score is " &lt;&lt; scores[i] &lt;&lt; '\n';
          }
          else { cout &lt;&lt; "Name not found. \n"; }
      }
  
  }
  </code></pre>
  
  <p>Specifically, the <code>while(cin &gt;&gt; locateName)</code>. Here is some additional information: Whenever I enter the names (John 5 Bob 6 Pete 9) I press <strong>CTRL + Z</strong> then <strong>ENTER</strong> to stop the <code>cin</code>. Then the program just ends. Is this(ctrlZ) what is causing the <code>while(cin &gt;&gt; locateName)</code> to not accept new values? Help is appreciated thank you.</p>