Write a ‘C’ program to append the contents of one file at the end of another file.
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp,*fq;
char ch;
clrscr();
fp=fopen("a.txt","r");
fq=fopen("b.txt","a");
if(fp==NULL)
{
printf("file does not exist");
exit(0);
}
if(fq==NULL)
{
printf("file does not exist");
exit(0);
}
while(1)
{
ch=fgetc(fp);
if(ch==EOF)
break;
fputc(ch,fq);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp,*fq;
char ch;
clrscr();
fp=fopen("a.txt","r");
fq=fopen("b.txt","a");
if(fp==NULL)
{
printf("file does not exist");
exit(0);
}
if(fq==NULL)
{
printf("file does not exist");
exit(0);
}
while(1)
{
ch=fgetc(fp);
if(ch==EOF)
break;
fputc(ch,fq);
}
getch();
}