P
Phlip
Newsgroupies:
Everyone (who is anyone) has written a 'fileToString()' function
before:
string fileToString(string fileName)
{
string result;
ifstream in ( fileName.c_str() );
char ch;
while( in.get(ch) ) result += ch;
return result;
}
It takes a file name and returns a string full of its contents. Text
contents assumed.
Here's the question: What's the fastest, or smallest, or smarmiest
possible Standard Library implementation? Could something like
std::copy() apply?
I wouldn't be surprised if mine were acceptably fast; if both ifstream
and std::string are buffered and delta-ed, respectively.
Please specify your library, if your solution pushes the envelop of
common C++ Standard compliance levels.
Everyone (who is anyone) has written a 'fileToString()' function
before:
string fileToString(string fileName)
{
string result;
ifstream in ( fileName.c_str() );
char ch;
while( in.get(ch) ) result += ch;
return result;
}
It takes a file name and returns a string full of its contents. Text
contents assumed.
Here's the question: What's the fastest, or smallest, or smarmiest
possible Standard Library implementation? Could something like
std::copy() apply?
I wouldn't be surprised if mine were acceptably fast; if both ifstream
and std::string are buffered and delta-ed, respectively.
Please specify your library, if your solution pushes the envelop of
common C++ Standard compliance levels.