tags:

views:

87

answers:

1

Hi,

How can I get the length in bytes of a stringstream.

stringstream.str().length();

would copy the contents into std::string. I don't want to make a copy.

Or if anyone can suggest another iostream that works in memory, can be passed off for writing to another ostream, and can get the size of it easily I'll use that.

+5  A: 

Assuming you're talking about an ostringstream it looks like tellp might do what you want: http://www.cplusplus.com/reference/iostream/ostream/tellp/

Mark B
I'm using http://www.cplusplus.com/reference/iostream/stringstream/with (std::ios_base::in | std::ios_base::out | std::ios_base::binary) constructor. tellp() works. Thanks.
Budric