Archived

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

Harvester

passing va_list as an argument...

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
can''t u just pass the string? try passing the char*

life is unfair, take advantage of it.
UNMB2 - if the link doesn''t work, try clicking it

Share this post


Link to post
Share on other sites