Skip to content

Instantly share code, notes, and snippets.

@levinotik
Created January 5, 2012 16:29
Show Gist options
  • Save levinotik/1565994 to your computer and use it in GitHub Desktop.
Save levinotik/1565994 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define IN 1
#define OUT 0
int main(int argc, char *argv[]) {
int arg;
for(arg = 0; arg < argc; arg++) {
puts(argv[arg]);
}
int c, wc, cc, lines, state;
state = OUT;
wc = cc = lines = 0;
while((c = getchar()) != EOF) {
+cc;
if(c == '\n')
++lines;
if(c == ' ' || c == '\n' || c == '\t')
state = OUT;
else if (state == OUT) {
state = IN;
++wc;
}
}
printf("%d %d %d\n", lines, wc, cc);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment