Mail Archives: djgpp/2000/09/28/23:45:24

From: "Richard Jernigan" <richard AT randomly DOT com>
Newsgroups: comp.os.msdos.djgpp,,
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: <bdUA5.12430$>
Date: Fri, 29 Sep 2000 03:43:03 GMT
X-Complaints-To: abuse AT home DOT net
X-Trace: 970198983 (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);


- Raw text -

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