vim编辑源代码 file1.c
#include “stdio.h”
int main(int argc,char *argv[])
{
FILE *fp1,*fp2;
char ch[maxsize];
if(argc!=3)
{
printf(“command error!\n”);
return -1;// exit(-1);
}
if( (fp1=fopen(argv[1],“r”))==NULL)
{
printf(“file %s cannot open”,argv[1]);
return -1;//exit(-1);
}
if ((fp2=fopen(argv[2],“wa+”))==NULL)
{
printf(“cannot creat file %s”,argv[1]);
return -1;// exit(-1);
}
while(fgets(ch,maxsize,fp1)!=NULL)
fputs(ch,fp2);
fclose(fp1);
fclose(fp2);
return 0;
}
编译 gcc file1 -o file1
最后执行 命令 ./file1 1.txt 2.txt