title: c++ stop asking for input on ctrl-d
body: <p>I am trying to read user input until ctrl-d is hit. If I am correct, ctrl+d emits an EOF signal so I have tried checking if <code>cin.eof()</code> is true with no success.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>string input;
  cout &lt;&lt; "Which word starting which year? ";
  while (getline(cin, input) &amp;&amp; !cin.eof()) {
      cout &lt;&lt; endl;
      ...
      cout &lt;&lt; "Which word starting which year? ";
  }
  </code></pre>