这是复制磁盘文件的一个程序,复制的是文本文件,IDE是vc6.0,楼主自己研究研究,类似的差不多就会了
#include"stdio.h"
#include<stdlib.h>
void main(int argc,char *argv[])
{
FILE *infp,*outfp;
char infile[40],outfile[40];
int c;
if(argc<3)
if(argc==2)
{
printf("output filename:");
gets(outfile);
argv[2]=outfile;
}
else
{
printf("input filename:");
gets(infile);
printf("output filename:");
gets(outfile);
argv[1]=infile;
argv[2]=outfile;
}
if((infp=fopen(argv[1],"r"))==NULL)
{
printf("Can't open the %s\n",argv[1]);
exit(1);
}
if((outfp=fopen(argv[2],"w"))==NULL)
{
printf("Can't open the %s\n",argv[2]);
exit(2);
}
c=getc(infp);
while(!feof(infp))
{
putc(c,outfp);
c=getc(infp);
}
fclose(infp);
fclose(outfp);
printf("ok\n");
}