title: How to print addresses (Hex values) in upper case in c++
body: <p>I'm trying to print the address(reference) of a variable in hex and that too in upper case. But I see that I'm able to print the hex equivalent of 77 in upper case, but not the address(reference) of a variable. Can somebody help me please?</p>
  
  <p>The following is the program I have the difficulty with.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  
  void print_nb_of_items(const int nb_of_apple, const int&amp; nb_of_pens)
  {
      cout &lt;&lt; "Number of apples = " &lt;&lt; nb_of_apple &lt;&lt; endl;
      cout &lt;&lt; "Number of pens = " &lt;&lt; nb_of_pens &lt;&lt; " Address = " &lt;&lt; uppercase &lt;&lt; hex &lt;&lt; &amp;nb_of_pens &lt;&lt; endl;
      cout &lt;&lt; "Hex output in uppercase = " &lt;&lt; uppercase &lt;&lt; hex &lt;&lt; 77 &lt;&lt; endl;
  }
  
  /* The main function */
  
  int main(int argc, char * argv[])
  {
      int nb_apple = 24;
      int nb_pens = 65;
      print_nb_of_items(nb_apple, nb_pens);
  
      return 0;
  }
  </code></pre>
  
  <p>The output for the program I got is:</p>
  
  <pre><code>Number of apples = 24
  Number of pens = 65 Address = 0xbffbd438
  Hex output in uppercase = 4D
  </code></pre>
  
  <p>I want the address to be printed as: 0xBFFBD438.
  How do I do that?</p>