Write a program to copy the content of one file into another file.

#include<conio.h>
#include<stdio.h>
int main()
{
FILE *fp1,*fp2;
char ch;
int i=0,l=0;
fp1=fopen("e:\\abc.txt","r");
fp2=fopen("e:\\xyz.txt","w");
if(fp1==NULL)
printf("error to open");
while(1)
{
ch=fgetc(fp1);
fputc(ch,fp2);
if(ch==EOF)
break;
}
printf("\n copy completed");
fclose(fp1);
fclose(fp2);
}

No comments:

Post a Comment