![]() |
![]() |
![]() |
![]() |
![]() |
|
You fetch each argument, and move the argument pointer to the next
argument, by deploying yet another macro,
va_arg. The va_arg macro takes as its first argument the
function's argument pointer. The va_arg macro takes as its second
argument the type of the argument to be fetched, which va_arg needs
so that it can properly move the argument pointer. For example, to fetch
the first of the optional arguments supplied to construct_trade,
which is of type double, you write the following:
va_arg (argument_pointer, double);
To fetch the second of the optional arguments, which is of type
int, you write a similar statement, but with int instead of
double:
va_arg (argument_pointer, int);
Finally, once all arguments are read, you clean up using
va_end with
the argument pointer as the sole argument:
va_end (argument_pointer);