实现copy功能的源代码

gzf3000 2000-06-09 11:03:00
关于拷贝文件。那一位大侠提供给我一个可以实现拷贝功能的源代码,最好使用FREAD()
FWRITE()。可以拷贝到不同目录。
...全文
167 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
halfdream 2000-06-10
  • 打赏
  • 举报
回复
把其中的:
fpSour=fopen(sour,"r");
fpDest=fopen(dest,"w");
改成这样吧:
fpSour=fopen(sour,"rb");
fpDest=fopen(dest,"wb");
wxz 2000-06-10
  • 打赏
  • 举报
回复
// 大致如下,没有加入错误检查
void Copy(char *sour,char *dest)
{
char buf[1025];
FILE *fpSour,*fpDest;
fpSour=fopen(sour,"r");
fpDest=fopen(dest,"w");
int n;
while(true)
{
n=fread(buf, 1024, 1, fpSour);
if(n>0)fwrite(buf,n,1,fpDest);
else break;
if(feof(fpSour))break;
}
fclose(fpSour);
fclose(fpDest);
}

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧