Here is some code
#include
main()
{
int (*p1)();
int (*p2)();
int fun1(), fun2();
p1 = fun1;
p2 = fun2;
display("Bye", p1, p2);
}
display(char *s,...)
{
int (*pp1)(), (*pp2)();
va_list ptr;
typedef int (*f)(); //This typedef is very important.
va_start(ptr,s);
pp1 = va_arg(ptr, f); // va_arg(ptr, int (*)()); would NOT have worked!
pp2 = va_arg(ptr, f);
(*pp1)();
(*pp2)();
}
fun1()
{
printf("\nHello!\n");
}
fun2()
{
printf("\nHi!\n");
}
Monday, April 6, 2009
How do I pass a variable number of function pointers to a variable argument (va_arg) function?
Posted by Raghu Kumar on 6:44 AM
RSS Feed
Twitter
Orkut