abul
July 31st, 2005, 05:30 AM
ifstream file1 ("1.txt", ios::in|ios::binary|ios::ate);
ifstream file2 ("2.txt", ios::in|ios::binary|ios::ate);
b1size = file1.tellg();
b2size = file2.tellg();
file1.seekg (0, ios::beg);
file2.seekg (0, ios::beg);
buffer1 = new char [b1size];
buffer2 = new char [b2size];
file1.read (buffer1, b1size);
file2.read (buffer2, b2size);
file1.close();
file2.close();
//cout << "the complete file is in a buffer";
fo.open("out.txt",ios::out);
for (i=0;i<b1size;i++)
//fo <<buffer1[i]<<"\t"<<"*"<<"\t"<<buffer2[i]<<"\t"<<"="<<"\t"<< buffer1[i]*buffer2[i]<<"\t";
fo <<buffer1[i]*buffer2[i]<<"\t";
fo.close();
delete[] buffer1;
delete[] buffer2;
by the above code i am handling 2 large file(1.txt and 2.txt) is both of 109 mb.i m trying to element by elemnet multiplication of the both file.but when i am loading both file into buffer its not a wise way.so i need to do it by taking one elements from both file and manipulate(*) it and then delete the buffer to load to load anoter element to manipulate.
plz send me by changing my code.
ifstream file2 ("2.txt", ios::in|ios::binary|ios::ate);
b1size = file1.tellg();
b2size = file2.tellg();
file1.seekg (0, ios::beg);
file2.seekg (0, ios::beg);
buffer1 = new char [b1size];
buffer2 = new char [b2size];
file1.read (buffer1, b1size);
file2.read (buffer2, b2size);
file1.close();
file2.close();
//cout << "the complete file is in a buffer";
fo.open("out.txt",ios::out);
for (i=0;i<b1size;i++)
//fo <<buffer1[i]<<"\t"<<"*"<<"\t"<<buffer2[i]<<"\t"<<"="<<"\t"<< buffer1[i]*buffer2[i]<<"\t";
fo <<buffer1[i]*buffer2[i]<<"\t";
fo.close();
delete[] buffer1;
delete[] buffer2;
by the above code i am handling 2 large file(1.txt and 2.txt) is both of 109 mb.i m trying to element by elemnet multiplication of the both file.but when i am loading both file into buffer its not a wise way.so i need to do it by taking one elements from both file and manipulate(*) it and then delete the buffer to load to load anoter element to manipulate.
plz send me by changing my code.