C/C++の宿題を片付けます 122代目
at TECH
198:デフォルトの名無しさん
09/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;
}
次ページ続きを表示1を表示最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
5379日前に更新/102 KB
担当:undef