Mail Archives: djgpp/1997/08/06/06:49:56
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 -