The va_arg() macros are used to pass a variable number of arguments to a
function.

First, you must have a call to va_start() passing a valid va_list and the mandatory argument that directly precedes the '…' argument of the function. If you only have one mandatory argument, it is that argument. You must have at least one mandatory argument. This argument can be anything; one way to use it is to have it be an integer describing the number of parameters being passed.

Next, you call va_arg() passing the va_list and the type of the argument to be returned. The return value of va_arg() is the current parameter.

Repeat calls to va_arg() for however many arguments you have.

Finally, a call to va_end() passing the va_list is necessary for proper cleanup.