title: int to Hex string (C++)
body: <p>I have done some research on how to convert an int to Hex string and found an <a href="https://stackoverflow.com/questions/5100718/int-to-hex-string-in-c">answer</a>, however what i need is a little bit different as you can see in the following code:</p>
  
  <pre><code>    int addr = 5386; // 
  
      std::string buffer = "contains 0xCCCCCCCC as hex (non ASCII in the string)";
      size_t idx = 0;
      idx = buffer.find("\xCC\xCC\xCC\xCC", idx);
      if (idx != string::npos) buffer.replace(idx, 4, XXX); // here i want to put the addr variable but as 0x0000150A 
  </code></pre>
  
  <p>What i need is a way to convert the <code>addr</code> variable to a hex string that has the <code>\x</code> in between the bytes like <code>"\x0a\x15\x00\x00"</code></p>
  
  <p>Thanks in advance.</p>