[LC++]Stringstream problems

Charles Randle charlesrandle at yahoo.com
Sat Nov 30 11:19:01 UTC 2002


Hi All,

1) Can someone please explain why the code snippet
below sets the fail bit after executing the statement
before the if test ??
#include <sstream>
#include <iostream>


int main() {
  ::std::stringstream grubbyStream;
  ::std::string cfgString= "CONFIGSTRING {";
  ::std::string blockName;
  ::std::string dummyString;

    // Set up stream 
    grubbyStream.str("");
    grubbyStream << cfgString;
    grubbyStream >> blockName;
    grubbyStream >> dummyString;

    grubbyStream << "WHAT HAPPENE";
    if (grubbyStream.fail()) ::std::cerr << "WE ARE
DEAD !!";
}


2) What exactly is the use of the stream function "
::std::ends "

Best Regards,
Charles Randle

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



More information about the tuxCPProgramming mailing list