how to extract binary data from stringstream variable in c++?
<p>I am new in C++, I usually use C. But now, I just find a good library that compress some information, with a special algorithm that it is very useful to my project. Then this library gave me as an answer: binary data which lives in a stringstream object. Since it is binary data, there are some bytes that are not an ASCII character. So what I want to do is extract the data and got their hexadecimal representation. How I can do it?
I have the following code:</p>

<pre><code>stringstream ss; \\variable in which I got the result from the library
bitset1.write(ss); \\with this instruction I got the binary information from the library
</code></pre>

<p>From there I try the following things:</p>

<p>1) Just print:</p>

<pre><code>cout &lt;&lt; hex &lt;&lt; ss;
</code></pre>

<p>2) Use the str method.</p>

<pre><code>cout &lt;&lt; hex &lt;&lt; ss.str();
</code></pre>

<p>3) Use the read buffer method.</p>

<pre><code>cout &lt;&lt; hex &lt;&lt; ss.rdbuf();
</code></pre>

<p>So, I think I am missing something, or maybe a lot, someone can help me? </p>
