Write a ‘C’ program to copy the contents of one file into another file.
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp,*fq;
char ch;
clrscr();
fp=fopen("a.c","r");
fq=fopen("b.c","w");
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);
}
fclose(fp);
fclose(fq);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp,*fq;
char ch;
clrscr();
fp=fopen("a.c","r");
fq=fopen("b.c","w");
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);
}
fclose(fp);
fclose(fq);
getch();
}