Copy the Content of One File to Another File

#include<stdio.h>
#include<conio.h>
void main()
{
          FILE *fp1,*fp2;
          char ch;
          clrscr();
          fp1=fopen("temp.txt","r");
          fp2=fopen("temp1.txt","w");
          if(fp1==NULL)
           {
              printf("\n File can not open ");
              getch();
              exit(0);
           }
         while((ch=fgetc(fp1))!=EOF)
            {
                   fputc(ch,fp2);
                   putch(ch);
            }
          printf("\n copied successfully ");
          fclose(fp1);
          fclose(fp2);
          getch();
}

Post a Comment

Previous Post Next Post