// cf. hashtrie.c, justhash.c, etc. #include #include int main(int argc, char **argv) { char buf[128]; int n = 0; for (;;) { if (!fgets(buf, sizeof buf, stdin)) break; char *p = buf; for (char *q = buf; *q; q++) { char c = *q; if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) { if (!*p) p = q; continue; } *q = 0; if (strlen(p)) n++; p = q; } if (strlen(p)) n++; } printf("%d total words\n", n); return 0; }