Problem With Pointers

Hi guys.

What is the difference between these:

  1. int *a[100];
  2. int (*a)[100];

The square array brackets (the '[' and ']') bind more tightly than the pointer operator, so the first declaration is equivalent to "int *(a[100])". Remember to read outwards from the identifier, so in the first declaration, a ("a") is an array ("a") of 100 ("a[100]") pointers ("*a[100]") to ints (int *a[100]").

In the second declaration, a is a pointer ("*a") to an array ("(*a)") of 100 ("(*a)[100]") ints.

2 Likes

Thank you very much.