C Programming - Complicated Declarations - Discussion

Discussion Forum : Complicated Declarations - Yes / No Questions (Q.No. 2)
2.
Is the following declaration correct?
char (* ( *f())[])();
Yes
No
Answer: Option
Explanation:
f is a function that returns a pointer to an array of pointers to functions that return a char.
Discussion:
3 comments Page 1 of 1.

Mndem said:   3 months ago
There is a rule of thumb to understand complex declarations in C. It's called Spiral Rule.

The idea is to start from the declaration symbol and then go in a clockwise direction starting with whatever is on the right of the declaration symbol and just name what you see. In this case it works like this:
Here, f is a function which returns a pointer to an array of pointers to a function which will return a char.

Venkatesh said:   1 decade ago
Can you be more clear @Kaustubh?

Kaustubh said:   1 decade ago
f is a function that takes 0 arguments, and returns a pointer to an array of pointers to functions that take 0 arguments and return a char.

The trick to understanding these complicated declarations is to go inside out.

Post your comments here:

Your comments will be displayed after verification.