Variable Parameters
Eric Conrad
econrad at thor.wright.edu
Wed Jan 3 08:05:15 AEST 1990
>From article <1169 at zip.eecs.umich.edu>,
by bagchi at dip.eecs.umich.edu (Ranjan Bagchi):
>
> I'm working, currently, on a project that involves a function that
> could take any number or arguments. I would like to pass it only
> those arguments, i.e. no "flags" at the end which tell the function
> to stop.
If I understand the ANSI C mechanism, which uses varargs.h, you have to
pass either some indication of the number of parameters or a sentinel
parameter. I used this method once several months ago and found it a
bit cumbersome.
An alternative is to write a stack handling module and use it to push
and pop parameters. The pop function could then return an stack empty
status. The additional source code would be on the push side.
-- Eric Conrad
+----------------------------------------------------------+
| Eric Conrad - Wright State University |
| "Progress was all right once, but it went on too long." |
+----------------------------------------------------------+
More information about the Comp.lang.c
mailing list