variable number of strings passed to function - how?

Henry Spencer henry at utzoo.uucp
Tue Oct 25 04:09:33 AEST 1988


In article <3533 at ihuxz.ATT.COM> burris at ihuxz.ATT.COM (Burris) writes:
>> I want to write a function that accepts a variable number of string
>> arguments.  What is a possible way to do this?
>
>In the C language arguments are placed on the stack in reverse order...

No.  In some C *implementations* they are placed on the stack in reverse
order.  In others they are placed on the stack in non-reverse order.  In
others they are passed in registers.  In yet others, different types of
arguments are passed in different kinds of registers.  An implementation
which uses registers will usually have to pass really big arguments on
an in-memory stack anyway.  And so on.  Use <varargs.h> or <stdarg.h>
(current practice and ANSI-C-draft practise respectively); they are the
*only* portable way to do this.
-- 
The dream *IS* alive...         |    Henry Spencer at U of Toronto Zoology
but not at NASA.                |uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list