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
VERSION : 2.0
OS : DOS
DATE : August 12, 1992 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.













  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: http://www.os2museum.com/wp/mtswslnk/