Message-Id: <200009282003.QAA26817@websmtp1.bellsouth.bigfoot.com> To: "A. Jans-Beken" , djgpp AT delorie DOT com Subject: Re:Help with variable argument-list (va_list) From: "Lets Go Canes!" Date: Thu, 28 Sep 2000 16:26:30 -0400 X-Originating-IP: 192.58.204.121 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 >second. >What is wrong in this example? >(the program compiles with DJGPP 2.95) > >// ---- 8< ---- 8< ---- >// file: test.cpp > >#include >#include >#include > > >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!