A pointer to 2d array

后端 未结 6 1761
予麋鹿
予麋鹿 2020-11-28 22:26

I have a question about a pointer to 2d array. If an array is something like

int a[2][3];

then, is this a pointer to array a?<

6条回答
  •  温柔的废话
    2020-11-28 23:13

    The [3] is a part of the type. In this case p is a pointer to an array of size 3 which holds ints.

    The particular type of an array always includes its size, so that you have the types int *[3] or int *[5], but not just int *[] which has undefined size.

    int *x[20]; /* type of x is int *[20], not just int *[] */
    int y[10][10]; /* type of y is int[10][10], not just int[][] */
    

提交回复
热议问题