Mail Archives: djgpp/2000/09/28/15:15:22

From: "A. Jans-Beken" <jansb000 AT wxs DOT nl>
Newsgroups: comp.os.msdos.djgpp,,
Subject: Help with variable argument-list (va_list)
Date: Thu, 28 Sep 2000 21:00:03 +0200
Organization: World Access
Lines: 44
Message-ID: <>
Mime-Version: 1.0
X-Trace: 970167011 13271882 (28 Sep 2000 18:50:11 GMT)
X-Complaints-To: abuse AT wxs DOT nl
NNTP-Posting-Date: 28 Sep 2000 18:50:11 GMT
X-Mailer: Mozilla 4.7 [en-gb] (Win98; I)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I am trying to create a wrapper for a function that uses a variable
argument list (like printf).
I have tried the code below, and the first argument works, but not the
What is wrong in this example?
(the program compiles with DJGPP 2.95)

// ---- 8< ---- 8< ----
// file: test.cpp

#include <iostream>
#include <stdio.h>
#include <stdarg.h>

void test_me(char *fmt, ... ) {
   va_list ap;

int main() {
   cout << "Test of va_list and co...\n";
   cout << "=========================\n\n";

   printf("The printf() function is working fine.\n");

   int i = 3;
   char *s = "Hello dear people";

   // The function test_me is a wrapper for printf.
   // How can I wrap a function with a variable number
   // of parameters?
   test_me("My arguments are %d and %s\n",i,s);

   return 0;
// ---- 8< ---- 8< ----

Please send answers to "jansb000 AT wxs DOT nl"

- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019