F
forrest
I wrote a function like this:
#define LEN 8
void foo(ostream& decry_stream )
{
ifstream ifile( filepath.c_str(), ios_base::binary );
while ( !ifile.eof() )
{
ifile.read((char *)(&aucCipherText), LEN);
read_count = ifile.gcount();
//do some work of decryption...
Decrypt(aucCipherText, aucDecryText, LEN);
for (i = 0; i < read_count; i++)
decry_stream << aucDecryText;
}
return;
}
The input file is about 1M bytes. The time cosumed when i used a
ofstream, strstream and stringstream as the parameter respectively is:
---------------------
ofstream ofile;
foo(ofile);
---------------------
ostrstream osst;
foo(osst);
#define LEN 8
void foo(ostream& decry_stream )
{
ifstream ifile( filepath.c_str(), ios_base::binary );
while ( !ifile.eof() )
{
ifile.read((char *)(&aucCipherText), LEN);
read_count = ifile.gcount();
//do some work of decryption...
Decrypt(aucCipherText, aucDecryText, LEN);
for (i = 0; i < read_count; i++)
decry_stream << aucDecryText;
}
return;
}
The input file is about 1M bytes. The time cosumed when i used a
ofstream, strstream and stringstream as the parameter respectively is:
---------------------
ofstream ofile;
foo(ofile);
---------------------
ostrstream osst;
foo(osst);