c语言中统计文件字符数
1、
#include <stdio.h> int main(void) { FILE *fp; char c1[128]; int lines = 0; fp = fopen("a.txt", "r"); while(fscanf(fp, "%s", c1) == 1) { lines++; } printf("lines = %d\n", lines); fclose(fp); return 0; }