Variable Number of Arguments

Q1:
Point out the error in the following program.
#include<stdio.h>
#include<stdarg.h>
void varfun(int n, ...);

int main()
{
    varfun(3, 7, -11, 0);
    return 0;
}
void varfun(int n, ...)
{
    va_list ptr;
    int num;
    num = va_arg(ptr, int);
    printf('%d', num);
}

A Error: ptr has to be set at begining

B
Error: ptr must be type of va_list

C Error: invalid access to list member

D No error

ANS:A - Error: ptr has to be set at begining

Using va_start(ptr, int);



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.