title: Can't point or store the elements of array in a new array
body: <p>I have an <code>arrFillRandom</code> function which fill an array with random numbers and prints it out. Here it is:</p>
  <pre><code>void arrFillRandom(int *arrayPtr, int sizeRow, int sizeColumn, int randomRange) {
      int i, j;
  
      arrayPtr = malloc(sizeof(int) * sizeRow * sizeColumn);
  
      for (i = 0; i &lt; sizeRow; i++)
          for (j = 0; j &lt; sizeColumn; j++)
              (arrayPtr + i)[j] = (rand() % randomRange);
      
      for (i = 0; i &lt; sizeRow; i++) {
          printf(&quot;\n&quot;);
          for (j = 0; j &lt; sizeColumn; j++)
              printf(&quot;%d\t&quot;, (arrayPtr + i)[j]);
      }
  }
  </code></pre>
  <p>And here is my <code>main</code>:</p>
  <pre><code>int main() {
  void arrFillRandom(int *arrayPtr, int sizeRow, int sizeColumn, int randomRange);
  
  int matrix1[2][3];
  int matrix2[3][2];
  
  int *ptr1, *ptr2;
  ptr1 = &amp;matrix1[0][0];
  ptr2 = &amp;matrix2[0][0];
  
  arrFillRandom(ptr1, 2, 3, 10);
  arrFillRandom(ptr2, 3, 2, 10);
  
  printf(&quot;\n%d&quot;, ptr1[0]);
  
  return 0;
  }
  </code></pre>
  <p>My problem is that <code>ptr1</code> or <code>ptr2</code> doesn't point to array which <code>arrFillRandom</code> filled before.
  In <code>arrFillRandom</code> function, I print out the matrix with random numbers. For example:</p>
  <blockquote>
  <p><strong>1, 0, 9</strong> // first row of first matrix</p>
  <p><strong>0, 9, 4</strong> // second row of first matrix</p>
  <p><strong>8, 2</strong> // first row of second matrix</p>
  <p><strong>2, 5</strong> // second row of second matrix</p>
  <p><strong>5, 5</strong> // third row of second matrix</p>
  </blockquote>
  <p>But in <code>main</code>, when I want to print first element of this matrix:</p>
  <pre><code>printf(&quot;\n%d&quot;, ptr1[0]);
  </code></pre>
  <p>This line should print <strong>1</strong>, but it prints irrelevant number such as 4096.</p>
  <p>So why I couldn't store that matrix in this array?</p>