delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/06/06:49:56

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.lang.c,comp.os.msdos.djgpp
Subject: Re: '...' handling (with djgpp, although likely ubiquitous)...
Date: Sun, 3 Aug 1997 20:25:20 +0100
Organization: None
Distribution: world
Message-ID: <pYMJiUBgsN5zEwoj@talula.demon.co.uk>
References: <33e5c2e0 DOT 51066140 AT news DOT bc1 DOT com>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
Lines: 28
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Burton Radons/Lothloriel, Hollow Dreams writes:
>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 '...'?  

1: #include <stdarg.h>
2: At the start of this function call va_start(args, format);
3: At the end of the function call va_end(args);

In between the calls to va_start() and va_end() you can work your way
through the argument list with the va_arg() function, eg:

int first = va_arg(args, int);
double next = va_arg(args, double);
char *another = va_arg(args, char *);

etc. You just have to make sure you retrieve the parameters using the
same types that were actually passed to the function...


--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.

- Raw text -


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