0% found this document useful (0 votes)
58 views

Program To Copy Contents of One File To Another

This C program code uses file handling functions like fopen, getc, putc, fclose to copy the contents of one text file "abc.txt" to another file "xyz.txt". It opens the source file for reading and destination file for writing, then uses a while loop to read each character from the source file and write it to the destination file until the end of file, and finally closes both files.

Uploaded by

Sandhya Aparna
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Program To Copy Contents of One File To Another

This C program code uses file handling functions like fopen, getc, putc, fclose to copy the contents of one text file "abc.txt" to another file "xyz.txt". It opens the source file for reading and destination file for writing, then uses a while loop to read each character from the source file and write it to the destination file until the end of file, and finally closes both files.

Uploaded by

Sandhya Aparna
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

www.eazynotes.

com

Gursharan Singh Tatla

Page No. 1

/***

Program to Copy Contents of One File to Another

***/

#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(); }

You might also like