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

Explain indirection?

631


How can I check whether a file exists? I want to warn the user if a requested input file is missing.

647


Add Two Numbers Without Using the Addition Operator

348


What is a memory leak? How to avoid it?

559


typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?

1060






What language is windows 1.0 written?

563


What are static variables in c?

616


Why header files are used?

633


What are the disadvantages of a shell structure?

682


What does do in c?

599


What's the right way to use errno?

611


Why we use int main and void main?

530


Explain what are multidimensional arrays?

590


how is the examination pattern?

1587


What are the header files used in c language?

572