C/C++の宿題を片付けます 122代目at TECH
C/C++の宿題を片付けます 122代目 - 暇つぶし2ch198:デフォルトの名無しさん
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