title: Why can't I find the value of EOF in C?
body: <p>I'm reading the book "The C Programming Language" and there is an exercise that asked to verify that the expression <code>getchar() != EOF</code> is returning 1 or 0. Now the original code before I was asked to do that was:</p>
  
  <pre><code>int main()
  {
      int c;
      c = getchar();
  
      while (c != EOF)
      {
          putchar(c);
          c = getchar();
      }  
  }
  </code></pre>
  
  <p>So I thought changing it to:</p>
  
  <pre><code>int main()
  {
      int c;
      c = getchar();
  
      while (c != EOF)
      {
          printf("the value of EOF is: %d", c);
          printf(", and the char you typed was: ");
  
          putchar(c);
          c = getchar();
      }
  }
  </code></pre>
  
  <p>And the answer in the book is:</p>
  
  <pre><code>int main()
  {
    printf("Press a key\n\n");
    printf("The expression getchar() != EOF evaluates to %d\n", getchar() != EOF);
  }
  </code></pre>
  
  <p>Could you please explain to me why my way didn't work?</p>