This is the mail archive of the libstdc++@sources.redhat.com mailing list for the libstdc++ project.


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

bug?? strstream vs stringstream



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

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