void main()
{
FILE *fp;
long int size;
char * buff;
if ((fp=fopen("w.dat","rb"))==NULL) {
printf("cannot open file\n");
exit(1);
}
fseek(fp,0,SEEK_END);
size=ftell(fp);
buff=(char *) malloc(size);
fseek(fp,0,SEEK_SET);
if (fread(buff,1,size,fp)!=size) {
printf("read error!!");
}
free(buff);
}
linux下C++读取文件,获取文件大小。
最新推荐文章于 2023-08-29 16:01:29 发布