1、
#include <stdio.h> #include <stdlib.h> int main() { int ch; int count = 0; FILE * fp; char fname[50]; printf("请输入文件名: "); scanf("%s", fname); getchar(); fp = fopen(fname, "r"); while ((ch = getc(fp)) != EOF) { putchar(ch); count++; } fclose(fp); printf(" "); printf("文件字符数为:%d", count); getchar(); return 0; }
2、