How to implement variable argument functions ?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the difference between 123 and 0123 in c?

937


What is data types?

806


What is %d called in c?

933


List the different types of c tokens?

823


Can static variables be declared in a header file?

811


which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;

2883


How can I recover the file name given an open stream?

752


What are local static variables? How can you use them?

840


printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions

850


What are the salient features of c languages?

846


What is data structure in c and its types?

803


Why pointers are used?

825


What is I ++ in c programming?

854


How can you increase the allowable number of simultaneously open files?

810


1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.

2531