用缓存,边读边写
CopyFile("in.dat","out.dat")
CopyFile(Source,Destination) // copy file from source to destination
{
// open source and destination files
src = fopen(Source,"rb");
if ( src == NULL )
Fatal("Could not open source file /"%s/" for reading.",Source);
dest = fopen(Destination,"wb");
if ( dest == NULL )
Fatal("Could not open file /"%s/" for writing.",Destination);
// read chunks from source, and copy to destination
#define COPY_CHUNK_SIZE 500
while (( 0 != (size = fread(buf,COPY_CHUNK_SIZE,src)) )
{
i++;
fwrite(buf,size,dest);
}
// close the files
fclose(dest);
fclose(src);
}