1

With respect to this question, we can declare a function that returns pointer to array as:

int (*function())[3]

which returns Ax3 array, ok.

How is the proper way to declare a function pointer that points this kind of function?

3 Answers 3

3
        f                 -- f
       *f                 -- is a pointer
      (*f)()              -- to a function
     *(*f)()              -- that returns a pointer
    (*(*f)())[3]          -- to a 3-element array 
int (*(*f)())[3]          -- of int
Sign up to request clarification or add additional context in comments.

Comments

0

Perhaps

int (*(*function_pointer)())[3];

(at least gcc seems to understand it)

Comments

0

See this reference, which is quite helpful. Note the techniques using typedefs

typedef int (*pfintarray())[3];

pfintarray myFunc() { /* etc

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.