C – Complex Pointers Declaration

How to read complex pointers in C Programming?

Assign the priority to the pointer declaration considering precedence and associative according to following table.

OperatorPrecedenceAssociative
(),[]1Left to right
*, identifier2Right to left
Data type3

Where:

() : This operator behaves as function operator.
[] : This operator behaves as array subscription operator.
* : This operator behaves as pointer operator.
Identifier : it is name of pointer variable.
Data type : Data types also includes modifier (like signed int, long double etc.)

How to read following pointer?

char (* ptr)[3]
  1. () and [] enjoys equal precedence. So rule of associative will decide the priority. Its associative is left to right So first priority goes to ().
  2. Inside the bracket * and ptr enjoy equal precedence. From rule of associative (right to left) first priority goes to ptr and second priority goes to *.
  3. Assign third priority to [].
  4. Since data type enjoys least priority so assign fourth priority to char.

Scroll to Top