- 198 名前:デフォルトの名無しさん mailto:sage [2009/01/18(日) 11:21:05 ]
- >>102
#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #define N 256 int main(void) { char b[N]; int c = 0, w = 0, l = 0; FILE *fp; fgets(b, N, stdin); *strchr(b, '\n') = '\0'; if (!(fp = fopen(b, "r"))) return 1; while (fgets(b, N, fp)) { int i = 0; while(b[i]) { c++; if (!isalpha(b[i++])) w++; } l++; } printf("%d character(s)\n%d word(s)\n%d line(s)\n", c, w, l); fclose(fp); return 0; }
|

|