title: c++ pass pointer address to function
body: <p>I want to change array values inside a function when pass the pointer address to this function.
  When I try to write to the array I receive a runtime error:</p>
  
  <pre><code>Exception thrown at 0x002D1D65 in interviews.exe: 0xC0000005: Access 
  violation writing location 0xCCCCCCCC.
  </code></pre>
  
  <p>I know I can do it in different way but its only for my understanding.</p>
  
  <p>this is the code:</p>
  
  <pre><code>void func(int **p){
      *p = (int*)calloc(3, sizeof(int)); //have to stay like thiis
      *p[0] = 1;  //this line work fine but I think I assign the value 1 
                  //to the address of the pointer
      *p[1] = 2;  //crashing here.
      *p[2] = 3;  
  }
  int main() {
      int* pm;       //have to stay like thiis
      func(&amp;pm);     //have to stay like thiis
      int x =  pm[1];
      cout &lt;&lt; x;
      return 0;
  }
  </code></pre>
  
  <p>I tried also with </p>
  
  <pre><code>**p[0] = 1;
  **p[1] = 2;
  </code></pre>
  
  <p>but its crash as well.</p>
  
  <p>What am I missing?</p>