#### Archived

This topic is now archived and is closed to further replies.

# va_list and ...

## Recommended Posts

i''m trying to simply get a ... from my function to fprintf. i''ve never used this before, and the only example i found on the internet required you to pass the number of args (it was an average function). all i really need is how to get this to work:
void blahblah(char * FormatString, ...)
{
fprintf(FormatString, ???);
}

what do i put in the ???

##### Share on other sites
C-FAQ question 15.12:
How can I write a function which takes a variable number of arguments and passes them to some other function (which takes a variable number of arguments)?

In short: You can't.

If you really want to do it, you could do it like this:
#include <stdio.h>#include <stdarg.h>void blahblah(char *fmt, ...){	va_list argp;	va_start(argp, fmt);	vfprintf(stdout, fmt, argp); //instead of stdout, you could use a *FILE.	va_end(argp);}

[edited by - TravisWells on March 16, 2003 11:51:39 PM]

##### Share on other sites
oops, i meant to have a FILE *, i just typed that real quick, i think thats it anyway. all i need to do is get the ... from my function to fprintf''s

##### Share on other sites
quote:
Original post by billybob
oops, i meant to have a FILE *, i just typed that real quick, i think thats it anyway. all i need to do is get the ... from my function to fprintf''s

Which is what vfprintf() does. The first parameter is FILE *

Qui fut tout, et qui ne fut rien

##### Share on other sites
oh i get it, sorry about that. thanks

• ### Forum Statistics

• Total Topics
628379
• Total Posts
2982353

• 10
• 9
• 15
• 24
• 11