Mail Archives: djgpp/2000/09/28/16:24:49

Message-Id: <>
To: "A. Jans-Beken" <jansb000 AT wxs DOT nl>, djgpp AT delorie DOT com
Subject: Re:Help with variable argument-list (va_list)
From: "Lets Go Canes!" <LetsGoCanes AT webmail DOT bellsouth DOT net>
Date: Thu, 28 Sep 2000 16:26:30 -0400
Reply-To: djgpp AT delorie DOT com

Hi all.

At Thu, 28 Sep 2000 21:00:03 +0200, you wrote:
>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;
>   va_start(ap,fmt);
>   printf(fmt,va_arg(ap,va_list));
>   va_end(ap);
>   }

In your example you would need to call vprintf instead
of printf.  With printf, you are only passing a single
argument - the first in the variable argument list.
With vprintf, you are passing the variable argument list
beginning with the specified argument as initialized by
the calls to va_arg.

Let's Go Canes!

- Raw text -

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