title: How to print hex from uint32_t?
body: <p>The code I have been working on requires that I print a variable of type <code>uint32_t</code> in hexadecimal, with a padding of 0s and minimum length 8. The code I have been using to do this so far is:</p>
  
  <pre><code>printf("%08lx\n",read_word(address));
  </code></pre>
  
  <p>Where read_word returns type uint32_t. I have used jx, llx, etc. formats to no avail, is there a correct format that can be used?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I have found the problem lies in what I am passing. The function read_word is returns a value from a uint32_t vector. It seems that this is the problem that is causing problems with out putting hex. Is this a passing by reference/value issue and what is the fix?</p>
  
  <p>read_word function:</p>
  
  <pre><code>uint32_t memory::read_word (uint32_t address) {
    if(address&gt;(maxWord)){
          return 0;
      }
  
      return mem[address];
  
  }
  </code></pre>
  
  <p>mem deceleration:</p>
  
  <pre><code>std::vector&lt;uint32_t&gt; mem=decltype(mem)(1024,0);
  </code></pre>