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\"喊裂滑
用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);
}
系统调用啊,看环境
c的话,没格式要求吗?