Declare Array of N Pointers

How do you declare an array of N pointers to functions returning pointers to functions returning pointers to characters?

Questions by Jegan Chakkravarthy   answers by Jegan Chakkravarthy

Showing Answers 1 - 9 of 9 Answers

Define a function pointer that returns a pointer to char


typedef char * (cfuncptr*) ();

Define a function pointer that returns a function pointer, which returns a pointer to char.

typedef  cfuncptr (ffuncptr *) (); 

Now Declare an array of these function pointers.

ffuncptr funcptr_table[N]; 


Non-typedef'd version:

char *(*(*funcArray[N])())();

Which is read as follows:

funcArray -- funcArray
funcArray[N] -- is an N-element array
*funcArray[N] -- of pointers
(*funcArray[N])() -- to functions
*(*funcArray[N])() -- returning pointer
(*(*funcArray[N])())() -- to function
*(*(*funcArray[N])())() -- returning pointer
char *(*(*funcArray[N])())() -- to char

Typedef'd version:

typedef char *charFunc(); // function returning pointer to char
tyepdef charFunc *ptrFunc(); // function returning pointer to charFunc
ptrFunc *funcArray[N];
 

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions