title: How to print a four character hexadecimal in C?
body: <pre><code>for (int x= 7; 0&lt;=x; x--) {
          size_t x_val = ((1&lt;&lt;4)-1) &amp; io&gt;&gt;x*4;
          printf(&quot;%lX&quot;, x_val);
  </code></pre>
  <p>Trying to print a hexadecimal number here after converting it from integer. While the conversion is successful, the output is <code>FFFFFFCD</code> instead of the desired output <code>FFCD</code>. How can I limit maximum 4 characters to be printed?</p>