stdarg

Erik Naggum enag at ifi.uio.no
Fri Feb 8 12:12:28 AEST 1991


In article <1991Feb7.043715.1224 at Think.COM>, Barry Margolin writes:
> In article <ENAG.91Feb6230643 at holmenkollen.ifi.uio.no>, Erik Naggum writes:
> >How do these functions determine how many arguments to use, and what
> >type they are?

> Well, consider a function taking a variable number of strings,
> followed by a null pointer.  The type is known by definition, and
> the number of arguments can be determined by looking at them.

> I'm not claiming that this is a good programming style, but an awful
> lot of people seem to be assuming that a fixed argument is needed in
> order to determine how to process the remaining arguments.  While
> this style could easily be replaced with one where there is an
> initial fixed argument containing the count of variable arguments,
> that's more prone to error: during program maintenance it is likely
> that an argument will be added but the argument count could easily
> be left unchanged.

You mean

	char *strmanycat (...)

which takes  n  char * arguments, the last of which being NULL?

Since the type of the argument is known, _and_ there has to be at
least one argument, why not use

	char *strmanycat (char *, ...)

which could actually use the first argument in the same way it will
use the remaining arguments?

(Thanks to Mike Taylor at System Simulation, UK, for the example.)

I'm left to believe that there is no real use for a (...) construct.

--
[Erik Naggum]					     <enag at ifi.uio.no>
Naggum Software, Oslo, Norway			   <erik at naggum.uu.no>



More information about the Comp.lang.c mailing list