title: counting newlines, spaces, and tabs
body: <p>This problem is from K&amp;R p. 20: Write a program to count blanks, tabs, and newlines.</p>
  
  <p>Here's my attempt:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main()
  {
    int character, whitespace = 0;
  
    printf("Enter some text, and press Ctrl-d when you're done.\n\n");
  
    while((character = getchar() != EOF) {
      if(character == (' ' || '\n' || '\t')) {
        ++whitespace;
      }
    }
  
    printf("\nYour text contains %d spaces, tabs, and lines.\n", whitespace);
  
    return 0;
  }
  </code></pre>
  
  <p>The program doesn't work. It always gives the answer 0 no matter how many spaces, tabs, and newlines the user text contains. Can anyone see the problem? There's one other strange thing: I have to press Ctrl-d twice for it to register. I have no idea why.
  Thanks!</p>