//参考源码如下
#include
#include
#include
int main()
{
char srcFile[64]={0};
char destFile[64]={0};
char buf[1024]={0};
FILE *src, *dest;
src=dest=NULL;
printf("Input source filename: ");
scanf("%s", srcFile);
printf("Input dest filename: ");
scanf("%s", destFile);
if(!(src=fopen(srcFile, "r"))){
printf("open src file error: %s\n", strerror(errno));
return -1;
}
if(!(dest=fopen(destFile, "a+"))){
printf("open dest file error: %s\n", strerror(errno));
return -2;
}
while(fread(buf, sizeof(char), 1024, src) != 0){
fwrite(buf, sizeof(char), 1024, dest);
memset(buf, 0, sizeof(buf));
}
fclose(src);
fclose(dest);
return 0;
}
希望采纳下答案哦!