Вот, только нет подсчета по кириллице (причина: разные платформы используют разные кодировки).
#include <stdio.h>
#include <ctype.h>
int main(int argc, char *argv[])
{
FILE *fp;
int line,word,ch_low,ch_up,digit,blank,other;
int word_flags;
int ch;
if (argc != 2) {
fprintf(stderr,"usage: %s TEXT_FILE\n",argv[0]);
return 1;
}
fp = fopen(argv[1],"r");
if (fp == NULL) {
fprintf(stderr,"Failed open file '%s'!\n",argv[1]);
return 1;
}
line = word = ch_low = ch_up = digit = blank = other = 0;
word_flags = 0;
while ((ch = fgetc(fp)) != EOF) {
int blank_flags;
putchar(ch);
if (ch == '\n') { /* check 'line' */
line++;
blank_flags = 1;
} else if (isspace(ch)) { /* check 'blank' */
blank++;
blank_flags = 1;
} else if (isdigit(ch)) { /* check 'digit' */
digit++;
blank_flags = 0;
} else if (islower(ch)) { /* check 'ch_low' */
ch_low++;
blank_flags = 0;
} else if (isupper(ch)) { /* check 'ch_up' */
ch_up++;
blank_flags = 0;
} else { /* other */
other++;
blank_flags = 1;
}
if (blank_flags) {
if (word_flags) { /* check end word */
word++;
word_flags = 0;
}
} else {
if (!word_flags) { /* check begin word */
word_flags = 1;
}
}
}
/* final word */
if (word_flags)
word++;
fclose(fp);
printf("line: %d; word: %d; ch_low: %d; ch_up: %d; "
"digit: %d; blank: %d; other: %d;\n",line,word,ch_low,
ch_up,digit,blank,other);
return 0;
}