PRODUCT : Borland C++ NUMBER : 733 VERSION : 2.0 OS : DOS DATE : October 19, 1993 PAGE : 1/1 TITLE : How to Use Variable Arguments /************************************************************* Example code for using a variable number of arguments. There is only one guaranteed way of accessing arguments passed using the ... mechanism. The standard header file as specified for ANSI C will provide declarations that can be used by a function that does not know the number or types of its arguments when it is compiled. *************************************************************/ #include void real_handler(const char*, va_list); void my_error_handler(const char* format, ...) { // ... va_list ap; va_start(ap,format); real_handler(format,ap); /* get arguments */ va_end(ap); exit(99); } void real_handler(const char* format, va_list ap) { // assume that 'format' tells us that // three arguments, a char*, an int, and a double, // are passed - in that order - by the va_list 'ap' char* p = va_arg(ap,char*); int i = va_arg(ap,int); double d = va_arg(ap,double); } DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that you received with the Borland product to which this information pertains.