In this post, I was write as we can get the parameters given to a function in language C, using stdarg library, that declares a type va_list and defines three macros for stepping through a list of arguments whose number and types are not known to the called function.
Below is show the declared functions in stdarg:
#include <stdarg.h> void va_start( va_list ap, last ); type va_arg( va_list ap, type ); void va_end( va_list ap ); void va_copy( va_list dest, va_list src );
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
As shown above, we can see that use the function va_start, which is declared in stdarg.h header. This function is responsible to get a varying number of arguments of varying types.
The var_start macro, initializes va_list for subsequent use by va_arg() and va_end(), and must be called first.