Write a C program to copy the contents of one file to another.

Program Code:
#include<stdio.h>
void main()
{
FILE *fp1, *fp2;
char ch;
fp1=fopen("old.txt","r");
fp2=fopen("new.txt","w");
if(fp1==NULL||fp2==NULL)
{
printf("file opening problem");
return;
}
while(!feof(fp1))
{
ch=fgetc(fp1);
fputc(ch,fp2);
}
fclose(fp1);
fclose(fp2);
getch();
}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: