Archived

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

passing va_list as an argument...

This topic is 6007 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

Greets. I have a function that takes a variable number of arguments (va_list). I want this function to send all the arguments, as received to another function, that also accepts a variable number of arguments (va_list). What i tried was:
  
int func1(char *something, ...){
 va_list v1;
 va_start(something, v1);
 func2(something, v1);
 va_end(v1);

 return (0);
}

int func2(char *something, ...){
 va_list v1;
 va_start(something, v1);
 //... do something with the data...

 va_end(v1);

 return (0);
}
  
obviously the above doesn''t work. I''ve also tried...
  
int func1(char *something, ...){
 func2(something);
 return (0);
}

int func2(char *something, ...){
 va_list v1;
 va_start(something, v1);
 //... do something with the data...

 va_end(v1);

 return (0);
}
  
Any ideas? thanx. ... LEMMINGS ... LEMMINGS ... LEMMINGS ... LEM..... SpLaSh!... Is it what we look like on the eyes of destiny or God? Are we LeMmIngS or WhAt!?

Share this post


Link to post
Share on other sites
void __cdecl VSFunction (int iVal, va_list pLST)
{
// Access pLST as an array.
}

void __cdecl Function (int iVal, ...)
{
va_list lstParams;
va_start (iVal, lstParams);
VSFunction (iVal, lstParams);
}

Also see "vsprintf".

Share this post


Link to post
Share on other sites