Course Solutions Uncategorized (Solved) : Pass 2d Array Function Parameter Pointer Example Code Passing Array Work Change Parameter Q38157829 . . . .

(Solved) : Pass 2d Array Function Parameter Pointer Example Code Passing Array Work Change Parameter Q38157829 . . . .

 

How do I pass a 2d array into a function when the parameter is apointer?

For example: In this code, passing the array as I did does notwork. If I were to change the parameter from int **grid to intgrid[][4] it would work. What should I be passing into thisfunction to make it work with pointers?

int islandPerimeter(int **grid, int gridRowSize, intgridColSize)
{
int landCount = 0;
int touchCount = 0;
int i, j;
for (i = 0; i < gridRowSize; i++)
{
for (j = 0; j < gridColSize; j++)
{
if (grid[i][j])
{
landCount++;
if (i+1<gridRowSize && grid[i+1][j])
{
touchCount++;
}
if(j+1<gridColSize && grid[i][j+1])
{
touchCount++;
}
}
}
}
return (4 * landCount – 2 * touchCount);
}

int main(void)
{

   int two[][4] = {{0,1,0,0},

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post