title: C Word Count program
body: <p>I am trying to write a program that will count the number of characters, words and lines in a text, the text is: </p>
  
  <pre><code>It was a dark and stormy night;
  the rain fell in torrents - except
  at occasional intervals, when it was
  checked by a violent gust of wind
  which swept up the streets (for it is
  in London that our scene lies),
  rattling along the housetops, and fiercely
  agitating the scanty flame of the lamps
  that struggled against the darkness.
  
    Edward Bulwer-Lytton's novel Paul Clifford.
  </code></pre>
  
  <p>I keep getting <code>62</code> instead of <code>64</code>, any suggestions?</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;ctype.h&gt;
  
  int main() {
      int tot_chars = 0;     /* total characters */
      int tot_lines = 0;     /* total lines */
      int tot_words = 0;     /* total words */
      int boolean;
      /* EOF == end of file */
      int n;
      while ((n = getchar()) != EOF) {
          tot_chars++;
          if (isspace(n) &amp;&amp; !isspace(getchar())) {
              tot_words++;
          }
          if (n == '\n') {
              tot_lines++;
          }
          if (n == '-') {
              tot_words--;
          }
      }
      printf("Lines, Words, Characters\n");
      printf(" %3d %3d %3d\n", tot_lines, tot_words, tot_chars);
  
      // Should be 11 64 375
      // rn     is 11 65 375
      return 0;
  }
  </code></pre>