Any code will not be portable, or even guaranteed to work (undefined behavior and all that)
However, it is possible, as the code below demonstrates:
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <stdarg.h>
void VarShowArgs(int n, va_list args)
{
for(int i=0; i<n; ++i)
{
printf("Arg #%d: %d\n", i+1, va_arg(args, int));
}
}
void ShowArgs_StartAtFourthParam(int n, ...)
{
va_list args;
int dummy;
va_start(args,n); // n is param #1 (value = 8)
dummy = va_arg(args, int); // Remove Param #2 from args (value = 1)
dummy = va_arg(args, int); // Remove Param #3 from args (value = 2)
// Show arguments starting at Param #4 (which should be value = 3)
VarShowArgs(n - 2, args); // Minus 2 because we removed 2 params from the args.
va_end(args);
}
int main(void)
{
// First param says how many more args there will be.
// This function shows the values starting at the 4th argument (value = 3)
ShowArgs_StartAtFourthParam(8, 1, 2, 3, 4, 5, 6, 7, 8);
getch();
return 0;
}
Output
Arg #1: 3
Arg #2: 4
Arg #3: 5
Arg #4: 6
Arg #5: 7
Arg #6: 8