title: Why getch() returns before press any key?
body: <pre><code>int main(int argc, char *argv[], char *env[])
  {
      printf("Press any key to exit.\n");
      getch();
      return 0;
  }
  </code></pre>
  
  <p>According to the man page,</p>
  
  <blockquote>
    <p><code>getch</code> should wait until any key is pressed</p>
  </blockquote>
  
  <p>...but in fact it returns directly before press any key. (The value returned is <code>-1</code>).</p>
  
  <p>Why?</p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>I'm on Linux. How can I implement <code>Press any key to exit.</code>, if not using <code>getch()</code>?</p>
  
  <p><code>getchar()</code> will only return after press Enter, it's not what I want.</p>