Category : C Source Code
Archive   : C-ALL.ZIP
Filename : TI733.ASC

Output of file : TI733.ASC contained in archive : C-ALL.ZIP

PRODUCT : Borland C++ NUMBER : 733
DATE : September 18, 1991 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.

void real_handler(const char*, va_list);
void my_error_handler(const char* format ...)
// ...
va_list ap;
real_handler(format,ap); /* get arguments */

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);

  3 Responses to “Category : C Source Code
Archive   : C-ALL.ZIP
Filename : TI733.ASC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: