   Passing on a variable number of arguments
  Hi there!I need to write a few functions that take care of error handling. So, for ease of use, they have to support a variable number of arguments, printf stile. Now getting the argument list into the function itself is not a problem, but if I want to then print those arguments using printf, how do I go about realising this?Something similar to this would be nice:int myError(const char *format, ...){   //... do something   printf(/*what do I have to put in here to make printf print something using the supplied arguments?*/);   //... do something else}//... call to the function:   return myError("Something catastrophic happened at %s!", myvar);//...  Is this even possible?Ciao, ¡muh! 
  Try vprintf and related functions.All of the stdio functions come in a version starting with v that will take a va_list of your arguments. ;  Thanks, but I'm not sure how this works - I'm looking at this page here for reference, btw: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_va_arg.2c_.va_end.2c_.va_start.aspI especially don't know how to get the correct va_list inside my myError function. I don't suppose this will yield the correct result, or?: int myError(const char *format, ...){    char *frm = format;    va_list marker;    va_start(marker, format);    vprintf(frm, marker);    //...}Ciao, ¡muh!   PS: As an addition, I'll later have to replace the printf call with another function that only supports the ANSI-C "..." variable number of arguments definition  [edited by - thebigMuh on February 4, 2004 11:11:15 PM];  you need a va_end too.   “Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”    — Brian W. Kernighan (C programming language co-inventor);axpCLogger::Info(const char* lpFmtCtrlStr,...){  va_list   mdArgList;  char mdTemp[4096];  va_start(mdArgList,lpFmtCtrlStr);  vsprintf(mdTemp,lpFmtCtrlStr, mdArgList);  va_end(mdArgList);}[source]will use vsprintf to format the arg list into a char array 