variable number of strings passed to function - how?

<10000>Ariel Aloni ariel at lznh.UUCP
Sat Oct 22 03:55:38 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?
>> 
>> -pete
>> 
>
>In the C language arguments are placed on the stack in reverse order
                                                     ^^^^^^^^^^^^^^^^
[ stuff deleted ]
This is a convention adopted by most compilers, it was never promised
by K&R (maybe somebody can enlighten us on ANSI-C ?).

>No, I didn't compile either example but they should give you a rough
>idea of how to do this. The examples assume that the stack grows in a
                                                      ^^^^^^^^^^^^^^^^
>negative direction.
^^^^^^^^^^^^^^^^^^^
bad assumption -- e.g. 3B2/600 running SysVr3.1 is growing in a
positive direction. Again, stack growth is never defined, it depends
on the implementation.

to the point :
use either varargs (see man page) or you can always go to the
simple "main" conventions (either "argv" convention or "arge"
convention) in this case.

>Dave Burris
>..att!ihuxz!burris

ariel


-- 
Ariel A. Aloni					att!ctsmain!raphel!ariel
(201) 576-2937



More information about the Comp.lang.c mailing list