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 61 times
0
![](../../users/profiles/4952002.webp)
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.
![](../../users/profiles/2173917.webp)
Sourav Ghosh
- 127,934
- 16
- 167
- 234
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.
![](../../users/profiles/-1.webp)
Community
- 1
- 1
![](../../users/profiles/1501794.webp)
Rahul Tripathi
- 152,732
- 28
- 233
- 299