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.txt","r");
fq=fopen("b.txt","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();
}

0 comments: (+add yours?)

Post a Comment