# include <stdio.h>
# include <stdlib.h>
int main(int argc, char *argv[])
{
int daytab[2][13];
int (*daytab)[13];
int *px;
return EXIT_SUCCESS;
}
I am studying pointers and having difficulty reading the int (*daytab)[13] declaration.
int *px is read as px is a pointer to a int.
How do you read int (*daytab)[13]?
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
+---------+
| +-----+ |
| ^ | | ( 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With