#include <fstream>
#include <string>
ifstream f( ... );
string s;
getline( f, s, '\0' ); // this presumes that there are no null characters in the file
f.close();
1 2 3 4 5 6 7 8 9 10 11 12
#include <algorithm>
#include <fstream>
#include <iterator>
ifstream f( ... );
string s;
f >> noskipws;
copy(
istream_iterator <char> ( f ),
istream_iterator <char> (),
back_inserter( s )
);
f.close();
These last two are interesting... The istream_iterator works using >>, alas, so it is rather slow... The final one has the multiple resizing to account for newline conversions...