title: HEX output to String c++
body: <p>I am trying to convert a <code>printf</code> output to a <code>std::string</code> variable. I have the following for loop:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>for(i=0; i&lt;53; i++) {
      printf("%02X", pbRecvBuffer[i]);
  }
  </code></pre>
  
  <p>The output of this loop are hex values like: <code>01445420434F2..</code>. My first attempt was using <code>stringstream</code> as the following: </p>
  
  <pre class="lang-cpp prettyprint-override"><code>stringstream os;
  
  for(i=0; i&lt;53; i++) 
      os &lt;&lt; std::hex &lt;&lt; pbRecvBuffer[i];
  
  std::cout &lt;&lt; os &lt;&lt; std::endl;
  </code></pre>
  
  <p>unfortunately this is given me the wrong result. Maybe someone just see it directly and can help me out. </p>