C++ Passing va_list to a function


Tell me how to implement the function:

int test(...){ printf(...);}

That is, pass the va_list parameters to the next function.


It's impossible to pass an undefined list of arguments just like that, there is no syntax for this in the language. However, the problem can be worked around, as noted here : the function you pass control to must have a variant that accepts va_list .

For your case, you can use vprintf :

void test(char *format, ...) // должен быть хотя бы один аргумент
    va_list args;
    va_start(args, format);
    vprintf(format, args);
Scroll to Top