C/C++编写一个使用系统调用从一个文件中读入数据并复制到另一个文件的程序

用C/C++编写一个使用系统调用从一个文件中读入数据并复制到另一个文件的程序。亲们,急求代码、

文件复制,就调 copy 命令就可以了。
system ("copy abc.dat def.dat"); 就把 abc.dat 复制到 def.dat 了。

如果文件名带空白,可以加 \" \" 括起来:
system ("copy \"abc A.dat\" \"def B.dat\" ");

文件名带路径,用双斜杠: \"D:\\dir\\abc A.dat\"
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-09-21
用c语言实现文件拷贝
#include<stdio.h>
#include<stdlib.h>
void main(int argc,char *argv[])
{
FILE *in,*out;
if(argc!=3){
printf("\n Usage: Hcopy sourcefile targetfile.\n");
exit(1);
}
if((in=fopen(argv[1],"rb"))==NULL){
printf("\n Cannot open the source file.\n");
exit(2);
}
if((out=fopen(argv[2],"wb"))==NULL){
printf("\n Cannot open the targetfile.\n");
exit(3);
}
/* start copy */
while(!feof(in))
putc(getc(in),out);
fclose(in);
fclose(out);
}
本回答被网友采纳
第2个回答  2012-09-25
系统调用啊,看环境
第3个回答  2012-09-23
c的话,没格式要求吗?
相似回答