Reading Complex Pointer Declarations
Explore how to interpret complex pointer declarations in C by applying systematic rules and examples. Understand valid and invalid pointer-function combinations and see how typedefs simplify function pointer syntax.
We'll cover the following...
A complex example
Let’s interpret the following declaration:
char*(*fptr())();
See the slides.
Why use complex declarations?
The previous declarations are useful and pretty common. We may want an array of functions for any number of valid reasons. We need to know how to read and interpret them. However, some declarations can become complex beyond the point of usefulness.
In the following example, we’ll see something that no one will do in practice. It’s hard to justify why anyone would write such a declaration. However, if we can read these declarations, then we are sure we can read the simpler but useful ones.
...