Your problem is that the rdbuf()
buffer for an ostringstream
is, as you might expect from the name, write only (the ostringstream
returns the string through the str()
method). You can't read the data back out of it through the buffer pointer.
Change your ostringstream
to stringstream
and it should work fine.