Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!agate!bionet!apple!bloom-beacon!tut.cis.ohio-state.edu!osu-cis!att!lzaz!lznh!ariel From: ariel@lznh.UUCP (<10000>Ariel Aloni) Newsgroups: comp.lang.c Subject: Re: variable number of strings passed to function - how? Message-ID: <1962@lznh.UUCP> Date: 21 Oct 88 17:55:38 GMT References: <434@tutor.UUCP> <3533@ihuxz.ATT.COM> Reply-To: ariel@lznh.UUCP (<10000>Ariel Aloni) Organization: AT&T, Lincroft, NJ Lines: 35 In article <3533@ihuxz.ATT.COM> burris@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