Jump to content
  • Advertisement

Archived

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

billybob

va_list and ...

This topic is 5577 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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
Invader''s Realm

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!