title: How to pass multidimensional arrays of pointers in function parameter, and manipulate it?
body: <p>So I have an array of pointers that this defined like so :</p>
  <pre class="lang-cpp prettyprint-override"><code>    sf::Sprite * game[3][3] = {{nullptr, nullptr, nullptr},
                         {nullptr, nullptr, nullptr},
                         {nullptr, nullptr, nullptr}};
  </code></pre>
  <p>It was working perfectly until I wanted to pass it into a function argument.
  I tried multiple parameters and arguments and this works :</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  
  void printTwoDPointersArr(int * myArray[][3])
  {
      for (int i = 0; i &lt; 3; i++)
          for (int j = 0; j &lt; 3; j++)
              std::cout &lt;&lt; *myArray[i][j];
  }
  
  int main()
  {
      int myRealArray[3][3] = {{0, 1, 2}, {3, 4, 5}, {0, 1, 2}};
      int * myPointingArray[3][3];
      for (int i = 0; i &lt; 3; i++)
          for (int j = 0; j &lt; 3; j++)
              myPointingArray[i][j] = &amp;myRealArray[i][j];
      printTwoDPointersArr(&amp;myPointingArray[0]);
  }
  </code></pre>
  <p>But then, if I want to create an second array that refers to the same array than myPointingArray, i just can't. I don't want a copy of the array, because copies are not updated when the original one is changed : I need a reference. I tried this :</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  
  void printTwoDPointersArr(int * myArray[][3])
  {
      int * mySecondArray = &amp;myArray[0];
      for (int i = 0; i &lt; 3; i++)
          for (int j = 0; j &lt; 3; j++)
              std::cout &lt;&lt; *mySecondArray[i][j];
  }
  
  int main()
  {
      int myRealArray[3][3] = {{0, 1, 2}, {3, 4, 5}, {0, 1, 2}};
      int * myPointingArray[3][3];
      for (int i = 0; i &lt; 3; i++)
          for (int j = 0; j &lt; 3; j++)
              myPointingArray[i][j] = &amp;myRealArray[i][j];
      printTwoDPointersArr(&amp;myPointingArray[0]);
  }
  </code></pre>
  <p>But I get the following error :</p>
  <pre class="lang-cpp prettyprint-override"><code>/path/main.cpp:5: error: cannot convert ‘int* (*)[3]’ to ‘int*’ in initialization
  /path/main.cpp:5:27: error: cannot convert ‘int* (*)[3]’ to ‘int*’ in initialization
      5 |     int * mySecondArray = &amp;myArray[0];
        |                           ^~~~~~~~~~~
        |                           |
        |                           int* (*)[3]
  </code></pre>
  <p>So, the question is : is there an easy way to manipulate multidimensional array of pointers, and to create a reference to them ?</p>
  <p>I am new to stack overflow, please tell me if I'm doing wrong.
  Thank you !</p>