title: In "The C Programming Language" Book by K&R Character Counting Example
body: <p>I have seen several posts in regards to the Character Counting section but none of them answers the question to not displaying the output correctly even after using <kbd>Ctrl+D</kbd> to exit.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main() {
      long nc;
      nc = 0;
      while (getchar() != EOF) {
          ++nc;
      }
      printf("%ld\n", nc); 
  }
  </code></pre>
  
  <p>After running this 
  <a href="https://i.stack.imgur.com/YnK8Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YnK8Y.png" alt="enter image description here"></a></p>
  
  <p>It doesn't count the characters just exit.
  What am I doing incorrectly? This is done in CLion on Mac</p>