I want to merge two files each of size 500MB of data in to a third file. The method that i know is given below
the problem during the execution time of this code the no of iteration is high since the fileCode:#include<stdio.h> #include<stdlib.h> int main() { FILE *fp1,*fp2,*fp3; char *buf1; buf1 = (char*)malloc(1024*sizeof(char)); fp1 = fopen("FileOne.t","wb"); fp2 = fopen("FileTwo.t","rb"); fp3 = fopen("FileThree.t","rb"); while(!feof(fp2)) { fread(buf1,1024*sizeof(char),1,fp2); fwrite(buf1,1024*sizeof(char),1,fp1); } while(!feof(fp3)) { fread(buf1,1024*sizeof(char),1,fp3); fwrite(buf1,1024*sizeof(char),1,fp1); } free(buf1); fclose(fp1); fclose(fp2); fclose(fp3); return 0; }
size is high.The machine is hanged some times when i run the .exe.How we merge the files in which the size of second and third file is high ?
Any solution better than this?
Regards,
Dave




Reply With Quote