title: How to exit a while-loop?
body: <pre><code>#include &lt;stdio.h&gt;
  main(void) {
     char ch;
     while (1) {   
        if ((ch = getchar()) != EOF) 
        {
           break;
        }
        putchar(ch);
     }
     return 0;
  }
  </code></pre>
  
  <p>How do I escape from this <code>while</code>? I had tried with EOF but it didn't work.</p>