Learning
Computer
Programming
Computer
Programming
Program No : 38 :
Write a program in C to merge two files ?
program no : 38
purpose : merge two files.
#include<"stdio.h">
#include<"conio.h">
int main(argc,argv)
int argc;
char *argv[];
{
FILE *fp,*fp1,*fpc;
char ch;
if(argc!=4)
{
printf("usage is wrong");
return;
}
fp=fopen(argv[1],"r");
if(fp==NULL)
{
printf("file opening error");
return;
}
fp1=fopen(argv[2],"r");
if(fp==NULL)
{
printf("file opening error");
return;
}
fpc=fopen(argv[3],"w");
if(fpc==NULL)
{
printf("file opening error");
return;
}
for(ch=getc(fp);feof(fp)==0;ch=getc(fp))
putc(ch,fpc);
for(ch=getc(fp1);feof(fp1)==0;ch=getc(fp1))
putc(ch,fpc);
fcloseall();
}




