Say you have 2 functions:
void func(int x,int y,...)
{
//do stuff
}
void func2(int x,...)
{
func(x,123,...);
}
How can you make this work, e.g pass the arg-list to the other function?
EDIT: this is a duplicate, can someone merge them or whatever?
You need a separate version that works with explicit argument lists:
void vfunc(int x, va_list args)
{
/* do stuff */
}
void func2(int x, ...)
{
va_list arg;
va_start(arg, x);
vfunc(x, arg);
va_end(arg);
}
This is the reason there are standard functions like vprintf()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With