That code is not a declaration, but it can be interpreted as an expression.
(*I_dont_know())[(int) ((*ptr))]
- Call the function
I_dont_know
with no arguments. This function returns a pointer to something. - Dereference the returned pointer to get some object.
- Meanwhile, dereference the value of
ptr
and cast it to anint
value. - Then pass that
int
value as the argument for the[]
(indexing) operator on that object returned in step 2. In C this could be another pointer or an array (arrays decay to pointers too). In C++ this could also be an object with the[]
operator overloaded. - As this expression is not on the left-hand-side of an assignment then the value returned from the
[]
operator sub-expression (i.e. the element at the*ptr
-index in the array) will be returned.
Assuming this is C, then the argument to the indexing operator should be cast as size_t
and not int
. If it’s C++ then it should only be cast to int
if the []
operator overload specifically accepts an int
parameter operand.
2
solved Decoding declaration(a combination of array and function pointers) in C [closed]