0

This produces garbage:

#include <iostream>
#include <sstream>
main()
{
    std::ostringstream s1;
    s1 << "s" << 1;
    std::cout << s1 << std::endl;
}

This produces garbage. I realize the fix is to use s1.str(). I'm wondering why ostream::operator<< can take the ostringstream arg if it "doesn't work properly".

John H.
  • 1,551
  • 1
  • 12
  • 18

0 Answers0