hey guys
i am using miracle c compiler on windows xp....
i am trying to figure out how does pointer to functions work.....
i have gone thru many tutorials but all have them failed to compile....
#include <stdio.h>
int sum(int x, int y)
{
return x + y;
}
int product(int x, int y)
{
return x * y;
}
int main()
{
int a = 13;
int b = 5;
int result = 0;
int (*pfun)(int, int);
pfun = sum;
result = pfun(a, b);
printf("\npfun = sum result = %d", result);
pfun = product;
result = pfun(a, b);
printf("\npfun = product result = %d", result);
}
//this source code is from
//http://www.java2s.com/Code/C/Function/Pointingtofunctions.htm
i get this error.......
C:\Program Files\Miracle C\work.c: line 21: Parse Error
'int (*pfun)(int, int)'
aborting compile
pls tell me wats wrong and also send me source code explaining the pointers to function