title: c++ How to pass a 2D array to a function that expects a pointer
body: <p>When I create a 2D array, I think the variable is just a pointer to the first element of the array. So I feel I should just be able to pass it straight to a function that expects a pointer as a parameter. It seems I can do this for a one dimensional array but not for multidimensional. Can someone explain why this is?</p>
  
  <pre><code>void the_function(int* the_array){}
  
  int main(){
     int the_array[3][3] = {{1,2,3},{1,2,3},{1,2,3}};
  
     the_function(the_array);
  }
  </code></pre>
  
  <p>If I try and compile this I get the following error:</p>
  
  <pre><code>candidate function not viable: no known conversion from 'int [3][3]' to 'int *' for 1st argument
  void the_function(int* the_array){}
       ^
  </code></pre>
  
  <p>But it works if I instead use a single dimension for the_array.</p>
  
  <p>I can make it work if I put a * before the argument in my function call like this:
      void the_function(int* the_array){}</p>
  
  <pre><code>int main(){
     int the_array[3][3] = {{1,2,3},{1,2,3},{1,2,3}};
  
     the_function(*the_array);
  }
  </code></pre>
  
  <p>But I feel like that * would be dereferencing the pointer, which I don't want to do. It should still be a pointer when passed to the function.</p>
  
  <p>Any ideas?</p>