TC2.0复制文本程序怎样编?

来源:百度知道 编辑:UC知道 时间:2024/05/12 18:32:57
假设E:\DOC\N001.TXT为原文件,读取其全部内容,
将其复制为E:\DOC\N002.TXT。
用TC2.0怎样编程?
不要用键盘输入输出,指定的文件名和路径名直接写到程序里。

/***************************************************
*Author :wacs5
*Date :20090111(YYYYMMDD)
*Function :复制文件
*Arguments :程序名 源文件路径及文件名 目的文件路径及文件名
*例 :程序名 E:\DOC\N001.TXT E:\DOC\N002.TXT
****************************************************/
#include <stdio.h>
#include <conio.h>
#include <string.h>
int main(int argc,char *argv[])
{
char *srcfile,*dstfile;
char command[300];
if (argc!=3)
{
printf("ERROR:\n\tUSAGE: exe file1 file2\n");
printf("Press any key to exit:");
getch();
exit(1);
}
sprintf(command,"copy %s %s",argv[1],argv[2]);
system(command);
printf("OK");
getch();
}