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");
}
Error: invalid function display() call
Error: invalid va_start(ptr, s);
Error: va_arg cannot extract function pointer from variable argument list.
Error: Rvalue required for t
Answer: Option
Explanation:
No answer description is available. Let's discuss.
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:

Your comments will be displayed after verification.