what is pointer to function in c with example

Answer:

short atletico(int);
short hamilton(int);
typedef short (*fun)(int);
void main(){
short x;
fun p1,p2;
p1=atletico;
p2=hamilton;
x=(*p1)((*p2)(10));
clrscr();
printf("%d",x);
getch();
}
short atletico(int x){
return x+10;
}
short hamilton(int x){
return x+10;
}

Output: 30
Explanation: Here p1 and p2 is pointer to such function which return type is short int and parameter is int type data.

Post a Comment