Stuff
public text v1 · immutable#include <stdio.h>
/* THis program counts all lines words and characters */
#define IN 1 /* In a word */
#define OUT 0 /* Outside a word */
main()
{
int c, nl, nw, nc, state;
state = OUT; // Initially you are out of a word
nl = nw = nc = 0;
while ((c = getchar()) != EOF) {
++nc;
if (c == '\n')
++nl;
if (c == ' ' || c == '\n' || c == '\t')
state = OUT;
else if (state == OUT) {
state = IN;
++nw;
}
}
printf("%d %d %d\n", nl, nw, nc);
}