title: C Disable command-line input
body: <p>I'm creating a ncurses program which reads system-wide keystrokes using AppKit. To clear the wall of text that accumulates on the command line while I run the program I execute this line of code before exiting the program.</p>
  
  <pre><code>while((c = getch()) != '\n' &amp;&amp; c != EOF) {}
  </code></pre>
  
  <p>My question is if there is a more efficient way to solve this. For example disabling command line input while the program executes.</p>
  
  <p>Edit:</p>
  
  <p>I ran some tests and my problem seems to be rooted in usleep and not ncurses or AppKit. Here is an example:</p>
  
  <pre><code>#include &lt;unistd.h&gt;
  
  int main() {
      usleep(5000000);
      return 0;
  }
  </code></pre>