bug?? strstream vs stringstream
Rob Willis
rob@e-critical.com
Wed Sep 13 01:02:00 GMT 2000
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
More information about the Libstdc++
mailing list