C Programming - Variable Number of Arguments - Discussion
Discussion Forum : Variable Number of Arguments - Point Out Errors (Q.No. 7)
7.
Point out the error in the following program.
#include<stdio.h>
#include<stdarg.h>
void display(char *s, ...);
int fun1();
int fun2();
int main()
{
int (*p1)();
int (*p2)();
p1 = fun1;
p2 = fun2;
display("IndiaBIX", p1, p2);
return 0;
}
void display(char *s, ...)
{
int (*pp1)();
int (*pp2)();
va_list ptr;
va_start(ptr, s);
pp1 = va_arg(ptr, int(*)());
(*pp1)();
pp2 = va_arg(ptr, int(*)());
(*pp2)();
}
int fun1()
{
printf("Hello");
}
int fun2()
{
printf("Hi");
}
Discussion:
5 comments Page 1 of 1.
Parth said:
1 decade ago
It points to array of integers and not array of integer pointers.
(1)
Shubhangi said:
1 decade ago
Va_arg cannot extract function pointer from variable argument list.
(2)
Anushiya said:
9 years ago
Please, anyone explain this briefly for me.
(1)
Deepika said:
8 years ago
Please explain it briefly.
Kritika said:
7 years ago
Please explain me.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers