variable number of arguments
Rich Williamson
richwill at swatsun.uucp
Fri Feb 19 08:37:13 AEST 1988
I'm trying to put together a simple formatted output routine for
X-Windows. I would like to be able to say something like this
MyXText( X, Y, formatString, arg1, ... , argn );
void
MyXText( X, Y, formatString, arg1, .... , argn )
int X;
int Y;
char *formatString;
??;
{
char TempString[100];
sprintf( TempString, formatString, arg1, ... , argn );
X-windows stuff here.
}
I would like to pass the necessary parameters to sprintf but I
don't know how to declare the arguments to MyXText. I don't know
how to declare a variable number of arguments. Is it even possible?
The family of printf() functions seem to be able to receive variable
arguments, so it would seem to possible.
K&R aren't much help. They say that it can be done but the resulting
code isn't portable. (p. 71) Do they mean that you have to pop
the arguments off the stack by hand? I don't need to do that, I
just want to pass the arguments transparently onto sprintf().
Thanks in advance for any helpful 'pointers'.
-- Richard Williamson
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
UUCP: seismo!bpa!swatsun!richwill
CSNET: richwill%swatsun.swarthmore.edu at relay.cs.net
--
UUCP: seismo!bpa!swatsun!richwill
CSNET: richwill%swatsun.swarthmore.edu at relay.cs.net
More information about the Comp.lang.c
mailing list