2D array variable pointer confusion

前端 未结 5 2090
日久生厌
日久生厌 2021-01-06 03:35

I have a basic doubt in 2D arrays (C Language). Consider a declaration of a 2D array as follows

int array[3][5];

Now when I do the followin

5条回答
  •  心在旅途
    2021-01-06 04:13

    You can understand in this way:

    array points to an 3 rows with 5 columns each

    when you do array+1, row changes so you go to 1st row. You should try accessing with *(array + 1).

    when you do *(array), you point to 0th row and *(array)+1 moves ahead in column so element is array[0][1]

提交回复
热议问题