title: How do i write this in cout/c++?
body: <p>How do i write the following function with cout? My main purpose is to actually print all the values to a file after i know how to use it with cout. std::hex does not work! </p>
  
  <pre><code>void print_hex(unsigned char *bs, unsigned int n)
  {
      int i;
      for (i = 0; i &lt; n; i++)
      {
          printf("%02x", bs[i]);
          //Below does not work
          //std::cout &lt;&lt; std::hex &lt;&lt; bs[i];
      }
  
  }
  </code></pre>
  
  <hr>
  
  <p>edit:</p>
  
  <p>cout print out values such as : r9{èZ[¶ôÃ