title: Sending variable size 2D array to function in C++
body: <p>I am trying to write  a function which takes variable size array and prints it. But i am having problem in function declaration argument list while compiling.</p>
  
  <p>The error is: </p>
  
  <pre><code>cannot convert ‘int (*)[(((sizetype)(((ssizetype)r) + -1)) + 1)]’ to ‘int**’ for argument ‘1’ to ‘void printHalf(int**, int, int)’
    printHalf( b, r, r);
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  void printHalf( int **a, int row, int col ) {  // Problem is here.
      for( int i=0; i &lt; row; i++) {
          for( int j=0; j &lt; col; j++) {
              if( i &lt;= j) {
                  cout &lt;&lt; a[i][j] &lt;&lt; " ";
              }
          }
          cout &lt;&lt; endl;
      }
  }
  
  int main() {
      int r;
      cout &lt;&lt; "No. of rows: ";
      cin &gt;&gt; r;
      int b[r][r];
  
      for( int i=0; i &lt; r; i++) {
          for( int j=0; j &lt; r; j++) {
              cin &gt;&gt; b[i][j];
          }
      }
  
      printHalf( b, r, r);
      return 0;
  }
  </code></pre>
  
  <p>What is causing this error, and how do i pass various arrays to function?</p>