In this program a word is defined by any sequence of characters that does not include a "-", " ", "\n", ":" or "\t".
So "howdy-hi:slig" would be three words in this program.
while ((iochar = getchar()) != EOF) {
if (iochar == '\n') {
line++;
word++;
}
if (iochar == ':' || iochar == '-' || iochar == '\t' || iochar == ' ') {
word++;
}
Instead of incrementing word everytime a whitespace is encountered, I know I need to skip all the extra whitespace characters that can separate two words, so that "hello - my : name is Earl." counts 5 words instead of 8.
Thank you, I appreciate it.