When I declare int a[5][3];
what exactly is a[2]
, is it a pointer to array or does it decays to a pointer to int a[2][0]
.
I want to talk about 2D arrays, and I am concerned in decay whether a[2]
decays or not when used independently.
Asked
Active
Viewed 71 times
0

Rohan Marley
- 21
- 2
-
1`a[2]` is an array of 3 `int`. It will decay to pointer to its first element, i.e. `a[2][0]` except in some cases like when used with `sizeof` operator. – haccks May 29 '15 at 07:09
2 Answers
1
For your case, a[2]
denotes an array of 3 int
s. It does not decay to a pointer all by itself. It has the type information.

Sourav Ghosh
- 133,132
- 16
- 183
- 261
1
Its a[2]
is an array of 3 int's.
However if you are looking for Array decaying then you can look for this what is array decaying?
I want to talk about 2D arrays, and I am concerned in decay whether a[2] decays or not when used independently.
It will not decay all by itself.

Community
- 1
- 1

Rahul Tripathi
- 168,305
- 31
- 280
- 331