C Program to Copy Content of One File into Another File
Get Certified in C Programming and Take Your Skills to the Next Level
Program 1
// Program for copy one file into other
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp1,*fp2;
char ch;
fp1=fopen("E://CData/employee.txt","r");
fp2=fopen("E://CData/newemp.txt","w");
if(fp1==NULL || fp2==NULL)
printf("File Error.....");
else
{
do
{
ch=fgetc(fp1);
fputc(ch,fp2);
}while(ch!=EOF);
fclose(fp1);
fclose(fp2);
printf("\nFile copied successfully.......");
}
}
Did you like this article? If Yes, please give DataFlair 5 Stars on Google

