title: Matrix, pointers, C*
body: <p>I have code like this:</p>
  
  <pre><code>void print_matrix(int **a, int n) {
      int i, j;
      for(i = 0; i &lt; n; i++) {
          for(j = 0; j &lt; n; j++)
              printf("%d\t", *(a+i*n+j));
          putchar('\n');
      }
  }
  
  int main () {
    int matrix[3][3];
  
    insert (matrix); /* Function that reads Matrix from stdin */
    print_matrix(matrix, 3);
    return 1; 
  }
  </code></pre>
  
  <p>I receive GCC error:</p>
  
  <blockquote>
    <p>expected ‘int **’ but argument is of type ‘int (*)[3]</p>
  </blockquote>
  
  <p>I read all related topics but I still couldn't find answer to my question, so before you mark it as duplicate please read it.</p>
  
  <p>Pointers are not Arrays, I understand that. I've read somewhere that elements are not sequential, in that case, this could happen: 111 222 333 -> 111 is address of first int array, 222 is address of second int array, and 333 is address of third int array. But if this is the case, I don't understand why GCC gives me an error.</p>
  
  <p>First I would like someone to confirm me that what I've read is true. Then I would really appreciate if someone could give me answer.</p>
  
  <p>Note that I understand that <code>*(a+i*n+j)</code> is incorrect in case that memory for matrix is not sequential. </p>
  
  <p>Best regards.</p>