title: C++ How do I convert int to hex char (as in 0x0A, not "0A")
body: <p>Sorry if this is hard to understand :P I'm trying to convert a decimal int value to a char value so I can write it in binary mode with fstream in c++. I did this: <code>char hexChar = 0x01; file.write(hexChar, size);</code>. That worked fine until I needed to write a decimal int from user. My question is, how do I convert decimal int to char hex value like this: <code>int decInt = 10; char hexChar = 0x00; hexChar = decInt; file.write(hexChar, size);</code> PS: I've been googling this for about an hour, and haven't found an answer. Every other solved problem with this has been decimal to ASCII hex value like "0A" using cout, not 0x0A using fstream.</p>