int main() { long num=0; FILE *fp; if((fp=fopen("fname.dat","r"))==NULL) { printf("Can’t open the file!"); exit(0); } while(!feof(fp)) { fgetc(fp); num++; } printf("num=%d\n",num); return 0; fclose(fp); }
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题