9.how do you write a function that takes a variable number
of arguments? What is the prototype of printf () function?
10.How do you access command-line arguments?
11.what does ‘#include<stdio.h>’ mean?
12.what is the difference between #include<> and #include”…”?
13.what are # pragma staments?
14.what is the most appropriate way to write a
multi-statement macro?

Answer Posted / deesha

explained how we can utilize the operator ellipsis (…) to
pass variable number of arguments to a function. I have
utilised there the concept of pointers to access the
variable arguments. The standard C Library provides support
to access these arguments. Use for this support
All you need is to know the last argument before the
ellipsis operator(At least one argument is must to use
variable arguments), let’s call it larg

suppose

fun(type var1,type var2,...)

is a function, then larg corresponds to var2

Now we need to declare the list using va_list
i.e.,

va_list al

now initialize it using va_start

va_start(al,larg);

Now to access each argument, we must know the expected type
of the argument

type var_name = va_arg(al,type);

When we have accessed all the variable arguments, we need to
clean up

va_end(al);

Using standard library, we can easily access the variable
arguments

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we increase size of array in c?

534


Can you think of a logic behind the game minesweeper.

2007


How can I rethow can I return a sequence of random numbers which dont repeat at all?

700


Declare the structure which contains the following members and write in C list of all students who score more than 75 marks. Roll No, Name, Father Name, Age, City, Marks.

679


When is a void pointer used?

672






What are the parts of c program?

629


how to print the character with maximum occurence and print that number of occurence too in a string given ?

2029


Can i use “int” data type to store the value 32768? Why?

754


What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?

934


Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?

574


what is the significance of static storage class specifier?

1659


Explain what is a program flowchart and explain how does it help in writing a program?

645


What is a null pointer in c?

591


What is the difference between array and pointer?

562


How do you use a 'Local Block'?

718