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 to Convert Temperature from Degree Centigrade to Fahrenheit
  • Bit Stuffing Program in C
  • C Program to Implement Circular Linked List
  • C Program to Calculate Sum of Odd Values in an Array
  • C Program to Find Simple Interest
  • C Program to Find Reverse of a Number using Recursion
  • C Program for String Comparison without using Built in Function
  • C Program to Implement STACK Operations Using Pointers
  • C Program to Find Roots of a Quadratic Equation
  • C Program Example to Initialize Structure Variable
  • C Program to Find Given Number is Armstrong or Not
  • C Program to Find Sum of N Natural Numbers
  • C Program to Find Sub String Position in Given String
  • C Program for Insertion Sort
  • Check a Character is Vowel or not Using C
  • Privacy Policy
  • Cookie Policy
© programming9.com 2026
Back to top