1:56 PM
C++ Program of COPY DATA FROM ONE FILE TO ANOTHER FILE

Write a Program of COPY DATA FROM ONE FILE TO ANOTHER FILE

#include<iostream.h> 
#include<conio.h> 
 
void main()
{
FILE *p,*q;
char file1[20],file2[20];
char ch;
clrscr();
printf("\nEnter the source file name to be copied:");
gets(file1);
p=fopen(file1,"r");
if(p==NULL)
{
printf("cannot open %s",file1);
exit(0);
}
printf("\nEnter the destination file name:");
gets(file2);
q=fopen(file2,"w");
if(q==NULL)
{
printf("cannot open %s",file2);
exit(0);
}
while((ch=getc(p))!=EOF)
putc(ch,q);
printf("\nCOMPLETED");
fclose(p);
fclose(q);
getch();
}
 
 
Note:
      If you want to change in this program please write through the comment on this page. you can also past similar program 
                 of c++ with output.your comment is valuable to the other user and person.
Views: 104 | Added by: vijoriya | Tags: program, File, Another, data, Copy, c++ | Rating: 0.0/0
Total comments: 0
avatar