Mail Archives: djgpp/2000/09/28/16:24:49
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
>second.
>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 -