Possible Duplicate:
How to understand complicated function declarations?
Spiral rule and ‘declaration follows usage’ for parsing C expressions
There is a section with the same title, "Complicated Declarations", in K&R's The C Programming Language book as you might have already read. I am just reading the book and trying to better myself in C language. After reading the section mentioned, I think I couldn't get the logic behind the syntax of C declaration statements. 1, 2, 3 and 4 are from that section 5 and 6 are from other pages.
int (*daytab)[13]
daytab: pointer to array[13] of intvoid (*comp)()
comp: pointer to function returning voidchar (*(*x())[])()
x: function returning pointer to array[] of pointer to function returning charchar (*(*x[3])())[5]
x: array[3] of pointer to function returning pointer to array[5] of chartypedef int (*PFI)(char *, char *)
creates the type PFI, for ``pointer to function (of two char * arguments) returning int. How does the syntax works here?
Finally, my questions are:
- Can you explain your ways of thinking and reading complicated declarations possibly by using examples above?
- Are the things like 1,3,4 practically usable and needed? If so, can you write some code examples?