/*
 *  CSC209 Assignment #1
 *  Jan 10, 2000
 *
 *  This program is designed to count the number of characters, words, and
 *  lines in a file, and print these totals out.
 *
 *  This program is broken. It has both compile-time and run-time errors. You
 *  are to find and fix each error. For each error, include a comment at the
 *  problem to explain what you did to fix the problem. Also, identify the type
 *  of each error (compile-time vs. run-time).
 *
 *  Don't fix anything which isn't strictly an error.
 */

#include <stdio.h>

#define IN	1
#define OUT	0

main()
{
  int c, nw, nc, state = OUT ;

  nw = nl = nc = 0 ;
  while ((c == getchar()) != EOF)
  {
    ++nc;
    if (c == '\n)
      ++ nl;
    if (c == ' ' || c == '\n' || c == '\t')
      state = OUT;
    else if (state == OUT) {
      state = IN;
      nw++;
  }
  printf("%d %d %d\n", nl, nw, nc);
}

