0

tried the following:

#define N 3
void print(int **arr, int m)
{
    int i, j;
    for (i = 0; i < m; i++)
        for (j = 0; j < N; j++)
            printf("%d ", arr[i][j]);
}

int main()
{
    int arr[][3] = { { 1, 2, 3 },{ 4, 5, 6 },{ 7, 8, 9 } };
    print(arr, 3);
    return 0;
}

and it crashed. when i replaced it with void print(int [][N], int m) it worked. couldent understand the difference. i was sure that ** means pointer to pointer, in other words array of pointers, in other words array of arrays. The same way array is treated as a pointer to the first cell.

Paul R
  • 208,748
  • 37
  • 389
  • 560
Jonathan
  • 69
  • 4

0 Answers0