0

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.

  • 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 Answers2

1

For your case, a[2] denotes an array of 3 ints. It does not decay to a pointer all by itself. It has the type information.

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.

Community
  • 1
  • 1
Rahul Tripathi
  • 152,732
  • 28
  • 233
  • 299