Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Are local variables initialized to zero by default in c?

995


What type is sizeof?

1010


Why isnt there a numbered, multi-level break statement to break out

1005


Explain how do you override a defined macro?

1025


What is #pragma statements?

1060


Where define directive used?

1039


Can a file other than a .h file be included with #include?

1111


How main function is called in c?

1080


why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???

1919


Write a program to generate random numbers in c?

1058


How #define works?

1059


What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

1239


What are the 32 keywords in c?

1054


How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?

984


How can I manipulate strings of multibyte characters?

1091