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
Is a house a mass structure?
Are global variables static in c?
Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..
What is a rvalue?
Why do we need a structure?
In this assignment you are asked to write a multithreaded program to find the duplicates in an array of 10 million integers. The integers are between -5000,000 to 5000,000 and are generated randomly. Use 10 threads, each thread works on 1000,000 integers. Compare the time needed to accomplish the task with single thread of execution program. Do not include the time to fill the array with integers in the execution time.
What are the features of c language?
program for reversing a selected line word by word when multiple lines are given without using strrev
is it possible to create your own header files?
List the different types of c tokens?
Can you mix old-style and new-style function syntax?
Are bit fields portable?
What is use of pointer?
What is ambagious result in C? explain with an example.
Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?