variable number of strings passed to function - how?

Karl Heuer karl at haddock.ima.isc.com
Sat Oct 22 06:17:39 AEST 1988


In article <3533 at ihuxz.ATT.COM> burris at ihuxz.ATT.COM (Burris) writes:
>In the C language arguments are placed on the stack in reverse order

This is not true in general.

>	string_func( "what", "why", "where", NULL );

In order for this to always work right, the NULL must be explicitly cast:
(char *)NULL or (char *)0 are the two correct ways to write it.  (Don't
followup to say you don't believe this. Ask Chris Torek (mimsy!chris) to mail
you the NULL article from his Frequently Asked Questions archive.)

>The examples assume that the stack grows in a negative direction.

If you write it with <stdarg.h>/<varargs.h>, you don't need to make that
assumption.

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list