Ask a Question

write aprogram which will merge the content of two files and copy into another blank file. sub:-c programming

on 2011-12-09 06:17:36   by rahul   on BCA  2 answers

Rajni

on 2011-12-08 10:30:00  

File Copy Program in C Language #include #include #include void main(int arg,char *arr[]) { FILE *fs,*ft; char ch; clrscr(); if(arg!=3) { printf("Argument Missing ! Press key to exit."); getch(); exit(0); } fs = fopen(arr[1],"r"); if(fs==NULL) { printf("Cannot open source file ! Press key to exit."); getch(); exit(0); } ft = fopen(arr[2],"w"); if(ft==NULL) { printf("Cannot copy file ! Press key to exit."); fclose(fs); getch(); exit(0); } while(1) { ch = getc(fs); if(ch==EOF) { break; } else putc(ch,ft); } printf("File copied succesfully!"); fclose(fs); fclose(ft); }

Deepanwita

on 2012-01-17 10:30:00  

Open arg1-file in read mode. Open arg3-file in append mode(create if not exist). copy arg1-file to arg3-file. close arg1-file. Open arg2-file in read mode. copy arg2-file to arg3-file. close arg2-file. close arg3-file. Done arg1-file and arg2-file merges and copied in arg3-file.