title: How to work on a sub-matrix in a matrix by pointer?
body: <p>I have a matrix of size n. Take an example: </p>
  
  <p><a href="https://i.stack.imgur.com/jSqgb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jSqgb.jpg" alt="enter image description here"></a></p>
  
  <p>My recursive function does the processing on the elements that lie in the border of the matrix. Now I want to call it (the recursive call) on the inner square matrix:</p>
  
  <p><a href="https://i.stack.imgur.com/Yj1HF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yj1HF.jpg" alt="enter image description here"></a></p>
  
  <p>This is the prototype of my recursive function:</p>
  
  <pre><code>void rotate(int** mat, size_t n);
  </code></pre>
  
  <p>I know that a 2D array is an array within an array. I know that <code>*(mat+1) + 1)</code> will give the memory address that should be the base address of my new matrix. This is what I tried:</p>
  
  <pre><code>rotate((int **)(*(mat+1) + 1), n-2)
  </code></pre>
  
  <p>But it does not work, and I get a segfault when  I try to access it with <code>[][]</code>.</p>