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

Is struct oop?

590


I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.

1912


Describe explain how arrays can be passed to a user defined function

611


What is the difference between null pointer and wild pointer?

646


Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings

2253






FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above

627


What is null pointer constant?

599


How are pointers declared in c?

603


What is c language used for?

563


#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }

724


Why do we need volatile in c?

750


What is the size of empty structure in c?

599


What are the key features in c programming language?

622


The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?

773


What does dm mean sexually?

820