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 Find Sum of 5 Subjects and Percentage
  • C Program for Quick Sort
  • C Program to Copy Contents From One File to Another
  • C Program to Compare Two Strings using strcmp()
  • C Program for Fibonacci Series using While Loop
  • C Program to Find Largest Element in an Array
  • C Program to Reverse Elements in Array
  • C Program to Find Nth Fibonacci Number Using Recursion
  • C Program to Find Area of a Triangle
  • C Program for Finding Factorial of a Number
  • C Program to Implement Single Linked List Operations
  • C program to Implement BREAK Statement
  • Evaluate Algebraic Expression (ax+b)/(ax-b)
  • C Program for Circumference of a Circle
  • C Program to Find Radius and Circumference of a Circle
  • Privacy Policy
  • Cookie Policy
© programming9.com 2025
Back to top