home *** CD-ROM | disk | FTP | other *** search
- # wordcount - count words in standard input
-
- define(EOF,-1)
- define(YES,1)
- define(NO,0)
- define(BLANK,32)
- define(NEWLINE,10)
- define(TAB,9)
- define(character,byte)
-
- character getc
- character c
- integer inword, wc
-
- call initio
-
- wc = 0
- inword = NO
- while (getc(c) != EOF)
- if (c == BLANK | c == NEWLINE | c == TAB)
- inword = NO
- else if (inword == NO) {
- inword = YES
- wc = wc + 1
- }
- call putdec(wc, 1)
- call putc(NEWLINE)
- call putc(EOF)
- stop
- end
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-