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; }
2024-01-16 08:01:22
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; }