Computer Science, asked by madhuryagowd8073, 1 year ago

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

Answers

Answered by Anonymous
3

#include<stdio.h>

#include<conio.h>

#include<stdlib.h>

 

void main() {

  FILE *fp1, *fp2;

  char ch;

  clrscr();

 

  fp1 = fopen("Sample.txt", "r");

  fp2 = fopen("Output.txt", "w");

 

  while (1) {

     ch = fgetc(fp1);

 

     if (ch == EOF)

        break;

     else

        putc(ch, fp2);

  }

 

  printf("File copied Successfully!");

  fclose(fp1);

  fclose(fp2);

}

Similar questions