programming9
  • Flowcharts
  • Programs
      • Back
      • C Programs
      • C++ Programs
      • Java Programs
      • Python Codes
      • HTML Codes
      • Java Script Codes
      • SQL Codes
  • Tutorials
      • Back
      • Java Tutorials
      • Competitive Programming
      • Python Tutorials
      • C Programming
  • Blog
  • Login

C Program to Copy Contents From One File to Another

Details
Written by: RajaSekhar
Category: C Programs
  • C-Files
#include <stdio.h>
main()
{
    FILE *fp1, *fp2;
    char ch;
    fp1 = fopen("abc.txt", "r");
    fp2 = fopen("xyz.txt", "w");
    while((ch = getc(fp1)) != EOF)
        putc(ch, fp2);
    fclose(fp1);
    fclose(fp2);
    getch();
}

 OUTPUT:

STEP 1: Create a New Text Document and Rename it as "abc.txt"

STEP 2: Write Some Content in that file and Save.

STEP 3: Now Compile the C Program and RUN it.

That's it. 

Now a new file will be created with a name "xyz.c" and all the content would copy from abc.txt to xyz.txt.


Previous article: C Program to Find Number of Characters and Words in a String Prev Next article: C Program to CONCATENATE Two Strings using strcat() Next
  • C Program for String Comparison without using Built in Function
  • C Program for Finding Factorial of a Number
  • C Program for Insertion Sort
  • Swap Two Static Numbers Using C
  • C Program to Print Prime Numbers upto a given Number
  • C Program to Implement Doubly Linked List Operations
  • C Program to Solve Sum of Series 1-x2/2! +x4/4!-x6/6!+x8/8!-x10/10!
  • Simulate Bankers Algorithm for Deadlock Avoidance Using C
  • C Program to Implement RADIX SORT
  • C Program for Sum of Squares of Numbers from 1 to n
  • C Program to Compare Two Strings using strcmp()
  • C Program for Optimal Page Replacement Algorithm
  • FCFS CPU Scheduling Algorithm Simulation Using C
  • C Program to Find Sum of All Array Values
  • C Program to Find Sum of Odd Integers
  • Privacy Policy
  • Cookie Policy
© programming9.com 2026
Back to top