I need some help with some 2D pointers and passing arrays to functions. Heres the code i got so far but i get a segmentation fault:
Code:#include <stdio.h>
float avg(int **array, int row, int col)
{
int i,j, count=0;
float calculation = 0, average;
for(i=0; i<row; i++)
{
for(j=0; j<col; j++)
{
calculation += array[i][j];
count++;
}
}
average = calculation/count;
return average;
}
int main(void)
{
int i, j;
int row=3, col=3, array[row][col];
for(i=0; i<row; i++)
{
for(j=0; j<col; j++)
{
printf("Enter value %d,%d \n", i, j);
scanf("%d",&array[i][j]);
}
}
float average = avg(&array[0][0], row, col);
}

