How to implement variable argument functions ?



How to implement variable argument functions ?..

Answer / swetcha

Variable-argument functions in C are inherently unsafe
since there is no language-level mechanism to ensure that
the actual arguments agree in type and number with the
arguments that the function will be using. There are
several ways to implement variable argument functions in C

You can try to implement such function by taking the
address of a formal argument and working your way through
the stack frame.A better alternative is to use the
__builtin_next_arg function on gcc and then work your way
up the stack. You can write your variable argument
functions using the standard macros in <stdarg.h> and
<vararg.h>.

Is This Answer Correct ?    8 Yes 2 No

Post New Answer

More C Interview Questions

What are the different properties of variable number of arguments?

0 Answers  


WAP to find that given no is small or capital

3 Answers  


What is wrong in this statement? scanf(“%d”,whatnumber);

0 Answers  


Write a C program to help a HiFi’s Restaurant automate its breakfast billing system. Your assignment should implement the following items: a. Show the customer the different breakfast items offered by the HiFi’s Restaurant. b. Allow the customer to select more than one item from the menu. c. Calculate and print the bill to the customer. d. Produce a report to present your complete program and show more sample output. Assume that the HiFi’s Restaurant offers the following breakfast menu: Plain Egg $2.50 Bacon and Egg $3.45 Muffin $2.20 French Toast $2.95 Fruit Basket $3.45 Cereal $0.70 Coffee $1.50 Tea $1.80

0 Answers  


To what value do nonglobal variables default? 1) auto 2) register 3) static

4 Answers  






Program to find largest of three numbers without using comparsion operator?

3 Answers  


write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.

0 Answers   HCL,


What is nested structure in c?

0 Answers  


Why can’t constant values be used to define an array’s initial size?

0 Answers  


What is break in c?

0 Answers  


Explain what happens if you free a pointer twice?

0 Answers  


How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?

2 Answers  


Categories