title: How to printf a memory address in C
body: <p>My code is:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  void main()
      {
      char string[10];
      int A = -73;
      unsigned int B = 31337;
  
      strcpy(string, "sample");
  
      // printing with different formats
      printf("[A] Dec: %d, Hex: %x, Unsigned: %u\n", A,A,A);
      printf("[B] Dec: %d, Hex: %x, Unsigned: %u\n", B,B,B);
      printf("[field width on B] 3: '%3u', 10: '%10u', '%08u'\n", B,B,B);
  
      // Example of unary address operator (dereferencing) and a %x
      // format string 
      printf("variable A is at address: %08x\n", &amp;A);
  </code></pre>
  
  <p>I am using the terminal in linux mint to compile, and when I try to compile using gcc I get the following error message:</p>
  
  <pre><code>basicStringFormatting.c: In function ‘main’:
  basicStringFormatting.c:18:2: warning: format ‘%x’ expects argument
  of type ‘unsigned int’, but argument 2 has type ‘int *’ [-Wformat=]
  printf("variable A is at address: %08x\n", &amp;A);
  </code></pre>
  
  <p>All I am trying to do is print the address in memory of the variable A.</p>