title: Breaking while loop by EOF
body: <p>I am trying to solve this problem and I need your help. </p>
  
  <p>I have this code...</p>
  
  <pre><code>while(a != EOF){
    scanf("%f",&amp;a);
    ...
  }
  </code></pre>
  
  <p>...and I want to terminate this loop by pressing CTRL+D. It works but I need to press it two times. I tried to use this</p>
  
  <pre><code>while(getchar() != EOF){
    scanf("%f",&amp;a);
    ...
  }
  </code></pre>
  
  <p>but the same result. Is there any way to end this loop by pressing CTRL+D only once?
  Thank you for any response.</p>