C语言如何进行文件复制?各位大哥进来帮帮忙啊~~~

sundna 2003-11-28 10:26:43
例如,复制a盘根目录下的文件ccw1.txt为a盘根目录下的ccw2.txt,则执行程序时输入的命令如下:程序名 a:\ccw1.txt a;\ccw2.txt


那位大哥能帮帮我,最好能把完整的程序写出来,谢谢了!
...全文
90 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dodgson 2003-11-28
  • 打赏
  • 举报
回复
本人是个音乐发烧友,通乐理。有没有人知道怎样用C语言编写音乐?告诉小弟一下吧!

是不是要用到一个叫Musical.h的库函数?我的电脑里没这个库函数,请问,怎样才能弄到这个库函数?
buaaaladdin 2003-11-28
  • 打赏
  • 举报
回复
最简单的,用system(char*)调用系统命令就可以了。

#include <stdlib.h>
#include <string.h>

int main(int argc, char** argv)
{
char command[50] = "copy ";
strcat(command, argv[1]);
strcat(command, " ");
strcat(commnad, argv[2]);
system(command);
}
daizh 2003-11-28
  • 打赏
  • 举报
回复
#include<stdio.h>
#include<stdlib.h>

int main(int argc,char *argv[])
{
FILE *fInput = NULL;
FILE *fOutput = NULL;
char ch = ' ';

if (argc != 3)
{
printf("Error input parameters!\n");
exit(-1);
}

fInput = fopen(argv[1],"rb");
fOutput = fopen(argv[2],"wb");

if ((NULL == fInput) || (NULL == fOutput))
{
printf("Error open file\n");
exit(-1);
}

while (!feof(fInput))
{
fread(&ch,1,sizeof(char),fInput);
fwrite(&ch,1,sizeof(char),fOutput);
}

fclose(fInput);
fclose(fOutput);

return 0;


}

70,022

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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