title: Convert unsigned char the way printf does in C++
body: <p>I have an <code>unsigned char</code> that I want to convert to hexadecimal. I know <code>printf("%02X", char)</code> gives me the output I want, but it is sent to the terminal and is thus of little use. How can I convert the character to hexadecimal and store it in a variable the same way printf does it?</p>