include <stdio.h>
include <stdlib.h>
/*
*src_path 源文件(不能是文件夹)
*des_path 目的文件(不是文件夹)
**/
int copy(const char * src_path,const char * des_path){
FILE* sfile;
FILE* dfile;
sfile = fopen(src_path,"rb");//设置文件打开方式为读二进制方式
dfile = fopen(des_path,"wb");//设置文件打开方式为写二进制方式
char buffer[1024];
while(!feof(sfile)){
fread(buffer0,1024,1,sfile);//读取二进制数据到buffer当中
fwrite(buffer0,sizeof(buffer),1,dfile);//将buffer当中的二进制数据写到文件中
}
//关流
fflush(dfile);
fclose(sfile);
fclose(dfile);
return EXIT_SUCCESS;
}
源代码如下: