#include <stdio.h>
#include <stdlib.h>
#define MAXLEN 1024
int main()
{
FILE * outfile, *infile;
outfile = fopen("1.bmp", "wb" );
infile = fopen("C:/1.bmp", "rb");
unsigned char buf[MAXLEN];
int rc;
while( (rc = fread(buf,1, MAXLEN,infile)) != 0 )
{
fwrite( buf, 1, rc, outfile );
}
fclose(infile);
fclose(outfile);
return 0;
}
注意:大文件读写依靠循环,非文字文件读写,在读写方式上加 “b";
Socket编程时大文件读写传输时可能出出现文件结尾部分无法到达,解决方法是接收端fflus(stdin)