[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

C++ ostreams on EGCS and Linux



Who here has used egcs extensively?  I'm getting some EXTREME weirdness
here.

First, why is the C++ standard 'ostringstream' simply 'ostrstream' in
the EGCS library?  This seems like a pretty big compatibility breaker. 
I'm using Stroustrup's _C++ Programming Language_ 3rd edition as my C++
reference.

If that wasn't bad enough, ostrstream is screwed up.  When I output
several lines to an ostrstream variable, garbage characters are getting
in there in totally inexplicable places, and parts of it are repeating. 
I have a function that's supposed to output a few lines of text in a
string.  When I just use cout << it displays normally.  But when I use
something like:

  ostrstream ret;
  ret << "Test " << 5 << endl;
  cout << ret.str();
  return ret.str();

it both prints the text screwed up and returns the screwed up text. 
(NOTE: it probably won't screw up with this simple example.  If you want
to try it I'll send you my latest airline simulator code and point you
to the real function.)

I changed the function to simply use a string and string concatination
operations and that fixed the problem for the display, but...

In another part of the program I want to take the returned text and
write it to a file.  I open an ofstream and << the return of this
function to it.  Guess what - there's garbage characters in the file!

I'm sure you'd need to see the code and the program output to get a good
idea of what's happening.  But has anyone successfully used this stuff
with complicated data?

Thanks,
Micah