Wednesday, May 2, 2012

Function pointer in C

#include<stdio.h>
int (*ptr)(int,int);//pointing to function with two integer
int fun(int a,int b)
{
int res;
res = a+b;
printf("Result after passing %d",res);
}

int main()
{
printf("The address of the function is %u\n",fun);
ptr = fun;// passing function to function pointer
(*ptr)(2,3);
}


No comments:

Post a Comment