How do I save a decimal number as hexadecimal on a single byte? : <pre><code>#include &lt;stdio.h&gt;
int main()
{
    int x = 255;
    char hex[4] = {0};
    hex[0] = 0x02;
    hex[1] = 0x20;
    hex[2] = 0xef;
    hex[3] = x;
    for(int i = 0; i &lt; 4; i++)
        printf("%X ", hex[i]);
}
</code></pre>

<p>This outputs " 2 20 FFFFFFEF FFFFFFFF". What should be changed so that it would output "02 20 EF FF"?</p>
