C++ Variable type of argument

Hello, I wants to write one function which pass its variable type of arguments to another function.
e.g. MyPrintf call printf of C but it accepts variable type of args and send it to Printf as it is.
Is there any way to do it ? Can I write my own va_list or other object ? But end function e.g. printf will treat it as like it is accepting parameters.
You can pass a variable number of parameters. But if your paramters are all of one type it is smarter to use a container like std::vector...
Yes, you can crate a va_list and call vprintf.
http://www.cplusplus.com/reference/cstdio/vprintf/?kw=vprintf

1
2
3
4
5
6
7
void MyPrintf (const char * format, ... )
{  va_list args;
    va_start (args, format);
    printf ("*** custom prefix *** ");  // Insert custom prefix
    vprintf (format, args);
    va_end (args);
}



Topic archived. No new replies allowed.