Original Post
Why does the input fail when passing the string buffer of a string stream into the get() method for an ifstream?
#include <sstream>
#include <fstream>
#include <iostream>
#include <cassert>
using namespace std;
char const * const text =
"This text is const \n\nconst for you and const for me. \n\nDo you like const text? \n\nI do.\n";
int main()
{
ofstream out("text.txt");
out << text;
out.close();
ifstream in("text.txt");
stringstream buffer;
while( !in.eof() )
{
in.get( *buffer.rdbuf() );
cout << buffer.str() << endl;
assert( in.good() );
}
in.close();
}