Path: utzoo!attcan!uunet!ingr!crossgl From: crossgl@ingr.UUCP (Gordon Cross) Newsgroups: comp.lang.c Subject: Re: variable number of strings passed to function - how? Summary: use the varargs convention for variable number of arguments Message-ID: <2773@ingr.UUCP> Date: 31 Oct 88 16:17:28 GMT References: <434@tutor.UUCP> <3533@ihuxz.ATT.COM> Organization: Intergraph Corp. Huntsville, Al Lines: 25 In article <3533@ihuxz.ATT.COM>, burris@ihuxz.ATT.COM (Burris) writes: > In the C language arguments are placed on the stack in reverse order > such that the first argument is the lowest index off of the stack pointer. > This allows you to pass the first argument as a count of the number of > following arguments. > > Example: [ example deleted to save space ] > > In both cases you set argp to the ADDRESS of the first string pointer > on the stack. The CONTENTS of argp is the POINTER to the first string. > Incrementing argp causes it to point to the second string pointer. > The proper way to access variable numbers of arguments passed to a routine is to use use !! Any assumptions about stack layout is just asking for trouble (for example some compilers pass the first couple of args in registers for efficiency reasons). Check your manuals or any good "C" programming book on how to use these macros.... Gordon Cross Intergraph Corp. Huntsville, AL