Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: using varargs function to call another varargs function Message-ID: <6048@brl-smoke.ARPA> Date: Fri, 3-Jul-87 22:21:09 EDT Article-I.D.: brl-smok.6048 Posted: Fri Jul 3 22:21:09 1987 Date-Received: Sun, 5-Jul-87 00:16:18 EDT References: <1332@rosevax.Rosemount.COM> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Distribution: world Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 20 /* example implementation of printf() using varargs */ #include printf( va_alist ) /* params: char * followed by variable arguments */ va_dcl { va_list ap; char *s; /* for the known parameter */ va_start( ap ); s = va_arg( ap, char * ); /* pick up first param */ vprintf( s, ap ); /* specially-designed function */ va_end( ap ); } NOTE: the function being called (vprintf() here) MUST be designed to accept a va_list parameter. Also, be very careful to balance va_start() with va_end(); these macros may have { and } respectively embedded in them, which affects their proper use in more complex situations.