One pointer variable can point to another variable.
Similarly one function can point another function.
This method is helped in callback mechanism. i,e) passing function as argument to anther function.
#include <stdio.h>
int add(int, int);
int add(int var1, int var2)
{
return var1 + var2;
}
int main(int argc, char **argv)
{
int x = 0;
int (*functionPtr)(int, int);
functionPtr = &add;
x = (*functionPtr)(10, 15);
printf("%d\n", x);
return 0;
}
No comments:
Post a Comment