title: Why can't I pass a pointer as an argument?
body: <p>I am attempting to retrieve a pointer via a function in c.  If the pointer is a return value from the function then it works.  But if I pass the address of the pointer to the function, I can't update the dereferenced pointer value (which should be the address stored in the pointer) from within the function.</p>
  
  <p>Please see the code and the output.  Why don't I get the same results with both <code>GetPointer1()</code> and <code>GetPointer2()</code>?  What am I missing?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdint.h&gt;
  
  uint8_t SrcArray[2][3] = {{11,12,13},{21,22,23}};
  uint8_t *p1;
  uint8_t *p2;
  
  void GetPointer1(uint8_t *p);
  uint8_t* GetPointer2(void);
  
  int main()
  {
      printf ("&amp;SrcArray[0][0]: %d\n", &amp;SrcArray[0][0]);
  
      GetPointer1(p1);
      p2 = GetPointer2();
  
      printf ("p1: %d\n",p1);
      printf ("p2: %d\n",p2);
  
      return 0;
  }
  
  void GetPointer1(uint8_t *p)
  {
      p = &amp;SrcArray[0][0];
  }
  
  uint8_t* GetPointer2(void)
  {
      return &amp;SrcArray[0][0];
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>&amp;SrcArray[0][0]: 6295604
  p1: 0
  p2: 6295604
  </code></pre>