## INDEX

### Pointer to array of function in c

Array of function means array which content is address of function and pointer to array of function means pointer is pointing to such array.

In other word we can say pointer to array of functions is a pointer which is pointing to an array which contents are pointers to a function.

Examples of pointer to array of function:

What will be output if you will execute following code?

#include<stdio.h>
int display();
int(*array)();
int(*(*ptr))();

int main(){
array=display;
array=getch;
ptr=&array;

printf("%d",(**ptr)());

(*(*ptr+1))();
return 0;
}
int display(){
int x=5;
return x++;
}

Output: 5
Explanation:

In this example:

array []: It is array of pointer to such function which parameter is void and return type is int data type.

ptr: It is pointer to array which contents are pointer to such function which parameter is void and return type is int type data.

(**ptr)() = (** (&array)) () //ptr=&array
= (*array) () // from rule *&p=p
=array  () //from rule *(p+i)=p[i]
=display () //array=display
(*(*ptr+1))() =(*(*&array+1))() //ptr=&array
=*(array+1) () // from rule *&p=p
=array  () //from rule *(p+i)=p[i]
=getch () //array=getch

Arithmetic operation with pointer
Pointer to function
Pointer to array of function
Pointer to array of string
Pointer to structure
pointer to union
Multi level pointer
Pointer to array of pointer to string
Pointer to three dimentional array
Pointer to two dimensional array
C tutorial

SHAOLIN said...

ultimate explanation of pointers!!!!!
hats off to u dude.

Sree said...

really very very useful for the beginners....

parul bansal said...

i m not understand pointer to array of function
any can explian more
because there are three function ,define only one function ,or display function call but how its work

subham jena said...

beautifully explained , nice stuff !!!!!!