Returning pointer to function from function
Hi,
I am learning function pointers and I found it little bit confusing.
I have wrote a program as shown below but it's not compiling.
Please suggest me where I am wrong.
Code:
#include<stdio.h>
int add( int a, int b) { return a+b; }
(int(*)(int,int) display();
void show( int(*)(int,int) );
int main()
{
int(*fun)(int,int) = NULL;
int(*fun)(int,int) = display();
show( int(*fun)(int,int) );
}
int(*)(int)(int) display()
{
return &add;
}
void show( int (*ptr)(int a,int b) )
{
int result = (*ptr)(56,63);
printf("%d",result) ;
}
Please let me know where I am wrong ?
Thanks