about summary refs log blame commit diff stats
path: root/wc.c
blob: e1445e10d59e0da217bef7e048cc6a5e73ee30eb (plain) (tree)


















                                                                  
#include <stdio.h>

int main() {
	long nc, nw, nl;
	int c;
	char inWord;
	nc = nw = nl = 0;
	while ((c = getchar()) != EOF) {
		if (c == '\n') ++nl;
		if (c == ' ' || c == '\t' || c == '\n')  inWord=0;
		else if (inWord == 0) {
			inWord = 1;
			++nw;
		}
		++nc;
	}
	printf("  %ld  %ld %ld\n", nl, nw, nc);
	return 0;
}