cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/06/07:35:38

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.lang.c,comp.os.msdos.djgpp
Subject: Re: '...' handling (with djgpp, although likely ubiquitous)...
Date: Wed, 06 Aug 1997 01:43:31 -0700
Organization: Alcyone Systems
Lines: 47
Message-ID: <33E83933.4F2C0B86@alcyone.com>
References: <33e5c2e0 DOT 51066140 AT news DOT bc1 DOT com>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Burton Radons/Lothloriel, Hollow Dreams wrote:

> char *rsprintf(const char *format, ...)
> {
>   va_list args;
>   char *buffer;
>   /* and on and on... */
> }
> 
> What would I have to do to... err... set 'args' to '...'?  That half of
> the
> reference manual was stolen several years ago, before I could get to it,
> so
> fluid-depth arguments are still an absolute mystery to me.

You don't have set it to anything.  Declaring a va_list auto variable
indicates that you're intercepting the arguments to the function (it hooks
into the stack) and works from there.  It should be the first declared
variable, incidentally.

Here is a function which does a modified printf:

    int printf2(const char *format, ...)
    {
        va_list args;
        int result;

        va_start(args, format);
        result = vprintf(format, args);
        va_end(args);

        return result;
    }

If you want to do something manually with the arguments, use the va_arg
macro.

Note that if you don't use both va_start and va_end at the appropriate
times then things will turn ugly.

-- 
       Erik Max Francis, &tSftDotIotE / email / mailto:max AT alcyone DOT com
                     Alcyone Systems /   web / http://www.alcyone.com/max/
San Jose, California, United States /  icbm / 37 20 07 N  121 53 38 W
                                   \
   "Love is not love which alters / when it alteration finds."
                                 / William Shakespeare, _Sonnets_, 116

- Raw text -


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