#include #define OUT 0 #define IN 1 int main() { printf("HELLO! THIS IS A BETTER VERSION OF THE UNIX PROGRAM CALLED wc!\n"); printf("THIS PROGRAM TAKES THE ENTER KEY AS A CHARACTER SO EVERYTIME YOU PRESS ENTER IT WILL GIVE YOU A CHARACTER PLUS!\n"); printf("THIS IS THE FINAL VERSION OF THIS WORD UTILITY PROGRAM\n"); while(1) { int x, state, words, lines, tabs, chars, blanks, letters; state = OUT; words = lines = tabs = chars = blanks = letters = 0; while((x = getchar()) != EOF) { ++chars; switch(x) { case ' ': ++blanks; break; case '\t': ++tabs; break; case '\n': ++lines; break; default: ++letters; break; } if (x == ' ' || x == '\t' || x == '\n') state = OUT; else if (state == OUT) { state = IN; ++words; } } printf("You have %d word(s)\n", words); printf("You have %d letter(s)\n", letters); printf("You have %d character(s) in total:\n", chars); printf("You have %d line(s)\n", lines); printf("You have %d tab(s)\n", tabs); printf("You have %d blank(s)\n", blanks); } }