Passing Variable Numbers of Arguments

Jonathan I. Kamens jik at athena.mit.edu
Tue Feb 12 09:55:15 AEST 1991


  If you're using an ANSI C compiler that has <stdarg.h>, then see the
documentation in K&R 2 (and whatever books you have that talk about ANSI C)
that talks about variable-argument functions.

  If you're not, and your system has <varargs.h>, then see the man page for
varargs for information about how to do variable-argument functions.

  In fact, you probably *are* going to end up using vprintf rather than being
able to call sprintf and convince it that some of youre function's arguments
are the arguments that it should use.  But that isn't such a big deal if you
have vprintf.  If you don't there are public domain implementations of it all
over the place, including one in comp.sources.misc or comp.sources.unix (I
forget which).

  I've found that a good place to see how variable argument stuff works with
<varargs.h> is the source code for GNU awk.  

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.lang.c mailing list