Continued from C variadic functions (a).

Here is how we can iterate over the arguments twice:

void foo(const char* format, ...) {
	va_list args, args2;
	va_start(args, format);
	va_copy(args2);
	// Access args and args2 here using va_arg
	va_end(args);
	va_end(args2);
}

Note that the order of calls of va_end doesn’t matter since behaviour of va_copy is as if va_start was called again for args2. Cf: va_start(3) variable argument lists - Linux man page.