c语言 13 - 7
1、
#include <stdio.h> int main(void) { FILE *fp; int ch; char filename[FILENAME_MAX]; printf("filename: "); scanf("%s", filename); if((fp = fopen(filename, "r")) == NULL) printf("\afile open failed.\n"); else { int num = 0; while((ch = fgetc(fp)) != EOF) { if(ch != '\n') num++; } fclose(fp); printf("characters number is: %d\n", num); } return 0; }