This is the mail archive of the
libstdc++@sources.redhat.com
mailing list for the libstdc++ project.
bug?? strstream vs stringstream
- To: libstdc++ at sources dot redhat dot com
- Subject: bug?? strstream vs stringstream
- From: Rob Willis <rob at e-critical dot com>
- Date: Wed, 13 Sep 2000 00:59:45 -0700
- Organization: eCritical
Getting strange behavior difference between strstream and stringstream
(you can not just drop in stringstream to replace strstream).
Try this code out:
#include <sstream>
#include <strstream>
#include <iostream>
int main()
{
std::ostringstream stm1;
stm1 << "123456789" << std::ends;
std::ostrstream stm2;
stm2 << "123456789" << std::ends;
std::string fname1 = stm1.str();
std::string fname2 = stm2.str();
std::cout << "Size of: " << fname1 << " = " << fname1.size()
<<std::endl;
std::cout << "Size of: " << fname2 << " = " << fname2.size()
<<std::endl;
}
Output:
Size of: 123456789 = 10 // ?? huh ??
Size of: 123456789 = 9 // makes sense
So is this a bug or a "feature"... I'm using an older image of egcs
(egcs-20000612).
--
Rob Willis
rob@e-critical.com