fread 函数参数问题
fread函数参数COUNT似乎可大可小对结果没多少影响,其实我这种理解可能是错误的,求大神指点迷津!!比如
#include<stdio.h>
#include<stdlib.h>
void main()
{
FILE *fps,*fpd;
char buffer[512],sfilename[30],dfilename[30];
int readnum;
printf("Please input source filename:\n");
scanf("%s",sfilename);
printf("Please input destine filename:\n");
scanf("%s",dfilename);
if((fps=fopen(sfilename,"rb"))==NULL)
{
printf("Source File open error!\n");
exit(1);
}
if((fpd=fopen(dfilename,"wb"))==NULL)
{
printf("Destine File open error!\n");
exit(1);
}
while((readnum=fread(buffer,1,10,fps))>0) //比如该处‘10’可以用‘20’,‘40’甚至可以用‘1’来代替对文本复制毫无影响,不知是什么原因,事实上源文件数据字节远大于20、40字节
{
fwrite(buffer,1,readnum,fpd);
}
printf("File copy ok!\n");
printf("%3d\n",readnum);
fclose(fps);
fclose(fpd);
}
[ 本帖最后由 lrcdddd 于 2014-8-9 22:45 编辑 ]