Apply spiral rule: is a technique known as the Clockwise/Spiral Rule which enables any C programmer to parse in their head any C declaration!
There are three simple steps to follow:
Starting with the unknown element, move in a spiral/clockwise direction; when encountering the following elements replace them with the corresponding English statements:
[X]
or []
=> Array X
size of... or Array undefined size of...
(type1
, type2
)
=> function passing type1
and type2
returning...
*
=> pointer(s) to
- Keep doing this in a spiral/clockwise direction until all tokens have been covered.
- Always resolve anything in parenthesis first! It will make sense;
+---------+
| +-----+ |
| ^ | | ( daytab) // daytab
int (*daytab) [13]; (*daytab) // daytab is a pointer
^ ^ | | (*daytab)[13] // daytab is a pointer to an array of 13
| | | | int(*daytab)[13] // daytab is a pointer to an array of 13 ints
| +-------+ |
+-------------+
Here are some answers to this question. Read them all.