title: extracting rows or columns from a 2D-array C++
body: <p>I'd like to make a function that receives a 2-dimensional array and returns one of its rows ('which') as a simple array. I wrote this:</p>
  
  <pre><code>int *row(int *array, int lines, int columns, int which)
  {
      int result[columns];
  
      for (int i=0; i&lt;columns; i++)
      {
          result[i] = *array[which][i];
      }
      return result;
  }
  </code></pre>
  
  <p>However, in line 7 I got the following error: invalid types 'int[int]' for array subscript. Any idea how to do this properly? I also tried to handle the 2D-array as an array of arrays, but didn't succeed. I'm novice, so please avoid too advanced concepts.</p>
  
  <p>Thanks for the help!</p>
  
  <p>UPDATE: thanks for the help! Now my code looks like:</p>
  
  <pre><code>int n;  //rows
  int m;  //columns
  int data[100][100];   
  int array[100];
  
  int *row(int *array, int rows, int columns, int which)
  {
      int* result = new int[columns];
      for (int i=0; i&lt;columns; i++)
      {
          result[i] = *array[which*columns+i];
      }
      return result;
      delete[] result;
  }
  
  int main()
  {
      array=row(data, n, m, 0);
  }
  </code></pre>
  
  <p>I still get an error in main: incompatible types in assignment of 'int*' to 'int [100]'</p>
  
  <p>What could be the problem now? I also don't know where to use the delete[] function to free up the array.</p>
  
  <p>Thank you very much for the help!</p>