stringstream question

From: Marc Schellens (m_schellens_at_hotmail.com)
Date: 11/04/03


Date: Tue, 04 Nov 2003 12:03:48 +0900


class myClass
{
stringstream ioss;
istream* is;

void f()
{
...
string initStr("");
ioss.str( initStr);
ioss.seekg( 0);
ioss.clear();
is->get( *ioss.rdbuf());
....
}

public:
        myClass( istream* is_): ioss(), is( is_) {}

...
};

works well, but:

void f()
{
...
// string initStr("");
ioss.str( ""); // HERE
ioss.seekg( 0);
ioss.clear();
is->get( *ioss.rdbuf());
....
}

causes the program reproducible to fail.
Is there something obvious wrong? (compiles without warning)
Is there a easier/better/clearer way to reset a stringstream?

thanks,
marc



Relevant Pages