/* This is an answer to sf22.txt. */ #include int numchars = 0; int numwords = 0; int numlines = 0; int main(void) { int thisisspace; int precedingwasspace = 1; char c; while (scanf("%c",&c) == 1) { ++numchars; if (c == '\n') ++numlines; thisisspace = ((c == ' ') || (c == '\n')); if (precedingwasspace && !thisisspace) ++numwords; precedingwasspace = thisisspace; } printf("%d %d %d\n",numchars,numwords,numlines); return 0; }