Function pointers

Below is a declaration of function pointer:
 
void * (*(*fp)(int))[10];


fp is a pointer to a function with int argument and return a
pointer to an array of 10 void pointers.

This is quite complicated declaration.
Who can give an example of a function prototype to initiate this function pointer?

I just wonder how to declare a function return an array.


I'm not completely sure I understand you but if you are asking for the prototype to a function that will return what you have there then I think you are after this:
 
void*(*(*func())(int))[10];
I mean fb is a pointer declare . How to initiate it?

Since it is a function pointer, so I think should be a function declare to imply with the function pointer declare.

1. I just try to understand more about function pointers.

2. I want to know how to declare a function to return a pointer to point to an array


Then I'm guessing you want something a bit like this:
1
2
3
4
5
6
7
8
// function taking int and returning array of 10 void pointers
void*(*func(int))[10]
{
	static void* array[10];
	return &array;
}

void*(*(*fp)(int))[10] = func; // Assign the address of func to our function pointer 
thanks
Topic archived. No new replies allowed.