title: C allocating dynamic memory in a function - same results
body: <p>I tryed to create a multi-dimensional array and I wrote a function but when I check my matrices,  I've realized my pointers's values are the same but their addresses are diffrent. Why :)</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int **matrix(int a,int b){
      int i;
      int **x;
      x = (int**)malloc(a * sizeof(int*));
      for (i = 0; i &lt; a; i++) {
          x[i] = (int*)malloc(b * sizeof(int));
      }
      return x;
  }
  
  int main()
  {
      int **m1, **m2;
      m1=matrix(3,3);
      m2=matrix(3,3);
      printf("Values: %d %d\n",m1[1][1],m2[1][1]);
      printf("Addresses: %d %d",&amp;m1[1][1],&amp;m2[1][1]);
      return 0;
  }
  </code></pre>