From: "Richard Jernigan" Newsgroups: comp.os.msdos.djgpp,rec.games.programmer,alt.games.programming References: <39D39533 DOT 33F46DA4 AT wxs DOT nl> Subject: Re: Help with variable argument-list (va_list) Lines: 23 X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Message-ID: Date: Fri, 29 Sep 2000 03:43:03 GMT NNTP-Posting-Host: 24.23.99.12 X-Complaints-To: abuse AT home DOT net X-Trace: news1.rdc2.pa.home.com 970198983 24.23.99.12 (Thu, 28 Sep 2000 20:43:03 PDT) NNTP-Posting-Date: Thu, 28 Sep 2000 20:43:03 PDT Organization: @Home Network To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com > I have tried the code below, and the first argument works, but not the > second. What is wrong in this example? > > void test_me(char *fmt, ... ) { > va_list ap; > va_start(ap,fmt); > printf(fmt,va_arg(ap,va_list)); > va_end(ap); > } va_arg evaluates to only the next element in the list. You need something like this: void test_me(char *fmt, ...) { va_list ap; va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); } --Richard