/* charloop.c, Dianna Xu

   Counts the number of chars and lines from keyboard input.
   Control-d on its own line signifies end of input.
*/

#include <stdio.h>

int main() {
  int nc = 0, nl = 0;
  char c;

  printf("Start typing, end with control-d on its own line:\n\n");
  while ((c = getchar()) != EOF) {
    nc++;
    if (c == '\n')
      nl++;
  }
  printf("Number of chars is %d and number of lines is %d\n", nc, nl);

  return 0;
}

