This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Problems with stringstream


At 10.48 25/10/2002 -0600, Jessee, Mark wrote:
Matt,

Your example fails as well.  But I found if I modify it a bit (see below),
it works fine.  Still not sure why though.  Thoughts?  Something to do with
flushing the stream?
I guess you're right.
Probably the standard out is not automatially flushed at the end of the program, so you don't get the last output.

Does this...

#include <iostream>
#include <sstream>
#include <string>
using namespace std;

int main ()
{
stringstream oss;
string mystr;

oss << "Sample string";
mystr=oss.str();

cout << mystr << endl; // flushes stdout

return 0;
}

...work ?

fwyzard



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]