Path: utzoo!mnetor!uunet!husc6!psuvax1!vu-vlsi!swatsun!richwill From: richwill@swatsun.uucp (Rich Williamson) Newsgroups: comp.lang.c Subject: variable number of arguments Message-ID: <1608@byzantium.UUCP> Date: 18 Feb 88 22:37:13 GMT Reply-To: richwill@byzantium.UUCP (Rich Williamson) Organization: Swarthmore College, Swarthmore PA Lines: 42 Keywords: arguments 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@relay.cs.net -- UUCP: seismo!bpa!swatsun!richwill CSNET: richwill%swatsun.swarthmore.edu@relay.cs.net