Program for Copy text from one file to another


#include<stdio.h>
#include<stdlib.h>
 main ()
 {
    FILE *file1,*file2;
    char c;
    int tabs=0,lines=0,spaces=0,charcters=0;
    file1=fopen("file7.txt","r");

     if(file1==NULL)
     {
      printf("File 1 Not Found\n");
      exit(0);
     }

    file2=fopen("file8.txt","w");
    if(file2==NULL)
    {
     printf("File 2 Not Found\n");
     exit(0);
    }
  while(1)
  {
   c=fgetc(file1);
   if(c!=EOF)
   {
    fputc(c,file2);
    }
    else
    {
     break;
    }
  }
  fclose(file1);
  fclose(file2);
 }

Output:

Store both text file and program in same folder.Here I named text file as file7.txt,file8.txt
Before Running ProgramFile 7 and File 8
After Running the Program File 8 has the following text copied from File 7

Comments