Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: problems with varargs Message-ID: <10301@mimsy.UUCP> Date: 22 Jan 88 15:37:31 GMT References: <7962@eleazar.Dartmouth.EDU> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 43 Keywords: varargs In article <7962@eleazar.Dartmouth.EDU> cmi@eleazar.Dartmouth.EDU (Theo Pozzy/R. Green) writes: >The basic idea is to have a routine like printf(), which calls another >routine, like fprintf(), passing one argument in addition to the arguments >passed to it. The basic trick (if I may phrase it so) is to have only one va_alist parameter anywhere in the chain. printf() does not call fprintf(); printf() calls vfprintf(): myprintf(fmt, va_alist) char *fmt; va_dcl { va_list vap; va_start(vap); myvfprintf(stdout, fmt, vap); va_end(vap); } myfprintf(f, fmt, va_alist) FILE *f; char *fmt; va_dcl { va_list vap; va_start(vap); myvfprintf(f, fmt, vap); va_end(vap) } myvfprintf(f, fmt, ap) FILE *f; char *fmt; va_list ap; { ... } -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris