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

Why is c called a mid-level programming language?

718


Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?

3045


what is the difference between 123 and 0123 in c?

711


Can we change the value of constant variable in c?

566


Is c easier than java?

562






What are the differences between Structures and Arrays?

599


How to get string length of given string in c?

599


Why should I use standard library functions instead of writing my own?

665


How will you declare an array of three function pointers where each function receives two ints and returns a float?

770


Explain built-in function?

583


What are the types of functions in c?

563


How many types of sorting are there in c?

600


Why c is called procedure oriented language?

573


Write a program to generate the Fibinocci Series

652


Explain union. What are its advantages?

610