Pages

This blog is under construction

Monday, December 10, 2018

What is pointer to function?


A pointer which holds the address of a function is known as a pointer to function. 


syntax:


//void parameter
int * function();  
int *(*ptr)();
ptr=&function;


// function with two parameters

 char * call(int *,float *);

           char *(*ptr)(int*,float *);
 ptr=&call ;
           
Here ptr is pointer to function.


Example:

Output: 10

Explanation:

Here function is a function whose parameter is void data type and return type is a pointer to int data type. 

No comments:

Post a Comment