Why does int*[] decay into int** but not int[][]?

前端 未结 4 1418
遥遥无期
遥遥无期 2020-11-27 03:34

I\'m trying to understand the nature of type-decay. For example, we all know arrays decay into pointers in a certain context. My attempt is to understand how int[]

4条回答
  •  盖世英雄少女心
    2020-11-27 04:28

    Two dimensional arrays are not stored as pointer to pointers, but as a contiguous block of memory.

    An object declared as type int[y][x] is a block of size sizeof(int) * x * y whereas, an object of type int ** is a pointer to an int*

提交回复
热议问题