title: Passing a row in a 2D array to a function using a pointer in C
body: <p>I need to write a program that scans in a 2D array and then finds the minimum value in each row by using a function.
  The prototype <code>int RowMin(int *prow, int ncols)</code> was given in the instructions. My problem is that I don't know for sure how to use the pointer. This was my best guess and it's not correct. The program crashes after I enter in the values of the array.</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #define MAX 10
  
  int RowMin(int *prow, int c);
  
  int main()
  {
      int a[MAX][MAX];
      int r, c, min;
      int i = 0, j = 0;
  
      printf("Enter number of rows &amp; columns of array:\n");
           scanf("%d %d", &amp;r, &amp;c);
  
      printf("\nEnter elements of 2-D array:\n");
           for(i=0; i&lt;r; i++)
           {
                    for(j=0; j&lt;c; j++)
                    {
                             scanf("%d", &amp;a[i][j]);
                    }
           }  
      for(i=0;i&lt;r;i++)
      {
          min = RowMin(i, c);
          printf("The min in row %d is %d",i, min);
      }    
      return 0;
  }   
  
  int RowMin(int *prow, int ncols)
  {
      int temp, i;
      int a[*prow][ncols]; //this is where it is messing up
      temp = a[*prow][0];
      for(i=0; i&lt;ncols; i++)
      {
          printf("Good5");
          if(temp &gt; a[*prow][i])
          {
              temp = a[*prow][i];
  
          }    
      }    
      return temp;
  }
  </code></pre>