Two files DATA1 and DATA2 contain sorted lists of integers. Write a C program to merge the contents of two files into a third file DATA i.e., the contents of the first file followed by those of the second are put in the third file.

Program Code:
#include<stdio.h>
void main()
{
FILE *fp1, *fp2,*fp3;
char ch;
fp1=fopen("program.txt","r");
fp2=fopen("new.txt","r");
fp3=fopen("merge.txt","a");
if(fp1==NULL||fp2==NULL||fp3==NULL)
{
printf("file opening problem");
return;
}
while(!feof(fp1))
{
ch=fgetc(fp1);
fputc(ch,fp3);
}
}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: