-3

I am trying to understand the difference between int *[5] and int (*)[5] and my simple code is as below.

int main()
{
    int a[5] = {10,11,12,13,14};
    int *ptr[5];
    ptr = &a;
}

  • What is the difference between int *[5] and int (*)[5] in C?
Guruprasad
  • 11
  • 3

1 Answers1

1

int a[5] - a is an array of 5 int.

int (*a)[5] - a is a pointer to an array of 5 int.

int a[5][4] - a is an mulitdimensional array with 5 dimensions of 4 int.

int *a[5] - a is an array of 5 int pointers.

Julian
  • 886
  • 10
  • 21
  • `mulitdimensional array with 5 dimensions of 4 int` does not make sense. `a` is a 5×4 array of `int`s, simply. Or, precisely, `a` is an array of 5 objects, each of which is an array of 4 `int`s. – Lxer Lx Jan 08 '20 at 10:27