#include<stdio.h>
#include<stdlib.h>
void mergeFiles(FILE *file1, FILE *file2, FILE *file3)
{
int num;
while(fscanf(file1,"%d",&num)!=EOF)
{
fprintf(file3,"%d\n",&num);
}
while(fscanf(file2,"%d",&num)!=EOF)
{
fprintf(file3,"%d",&num);
}
}
int main(int argc, char *argv[]){
if(argc!=4) {
printf("Usage : %s<data1><data2><data>\n",argv[0]);
return 1;
}
FILE *file1=fopen(argv[1],"r");
FILE *file2=fopen(argv[2],"r");
FILE *file3=fopen(argv[3],"w");
if(file1==NULL || file2==NULL || file3==NULL){
fprintf("Error Opening files\n");
return 1;
}
merge files(file1,file2,file3);
printf("Merged content written to %s\n",argv[3]);
fclose(file1);
fclose(file2);
fclose(file3);
return 0;
}
这段代码有什么错误?
使用命令行参数在c中复制数据3中的两个数据文件时出错
我认为您遇到的主要问题有以下几个: