[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: pointers to functions
This Code May Work For You
void fun1(void)
{
printf("Fun1\n");
}
void fun2(void)
{
printf("Fun2\n");
}
void fun3(void)
{
printf("Fun3\n");
}
void CallFuns( void (*f1)(), void (*f2)() , void (*f3)())
{
(*f1)();
(*f2)();
(*f3)();
}
int main()
{
void (* myfuns[3])(void);
int i;
myfuns[0] = fun1;
myfuns[1] = fun2;
myfuns[2] = fun3;
i = 0;
CallFuns(myfuns[i],myfuns[i+1],myfuns[i+2]);
printf("\n");
i = 1;
CallFuns(myfuns[i],myfuns[i-1],myfuns[i+1]);
}
--------------------------------
Muralidhar