Write a ‘C’ program to copy content of one file into another file

#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp1,*fp2;
char ch,fname1[20],fname2[20];
printf("\n enter sourse file name");
gets(fname1);
printf("\n enter sourse file name");
gets(fname2);
fp1=fopen(fname1,"r");
fp2=fopen(fname2,"w");
if(fp1==NULL||fp2==NULL)
{
printf("unable to open");
exit(0);
}
do
{
ch=fgetc(fp1);
fputc(ch,fp2);
}
while(ch!=EOF);
fcloseall();
getch();
}

9 comments:

  1. plz sent a c ..........
    Program to copy the content of one file to another and count the number of characters,line and words in a above fie

    ReplyDelete
  2. header file must be use to call exit function..and the return type should be int.

    ReplyDelete
  3. this program not be run. for exit(0); in error .

    ReplyDelete
  4. what header file is needed for exit(0) line..??

    ReplyDelete
  5. Please send this PROGRAM TO COPY CONTENTS OF ONE FILE TO ANOTHER FILE AND FIND THE NO OF CHARACTERS AND WORDS IN THE ABOVE FILE

    ReplyDelete
  6. i wana make a program in which data should be store in the file and save it by user and then if he wana to compare the data it should open the data which is save in the file by user .....sir plzzz tell me the program for this thing

    ReplyDelete
  7. create a c program to create text file and display content of the text file

    ReplyDelete