Sunday, August 28, 2011

Pass a Function Pointer as an Argument







#include
int Dolt(float a,char b,char c){printf("Dolt\n");return int(a+b+c);}
void passPtr(int (*pt2function)(float a,char b,char c)){
 int result=(*pt2function)(12,'a','b');// call using function pointer;
 printf("%d\n",result);
}
int main(){
 //pass a function pointer as an argument
 passPtr(&Dolt);
 getchar();getchar();
 return 0;
}

No comments:

Post a Comment