Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!decvax!dartvax!eleazar!cmi From: cmi@eleazar.Dartmouth.EDU (Theo Pozzy/R. Green) Newsgroups: comp.lang.c Subject: problems with varargs Message-ID: <7962@eleazar.Dartmouth.EDU> Date: 20 Jan 88 21:26:28 GMT Reply-To: cmi@eleazar.Dartmouth.EDU (Theo Pozzy/R. Green) Organization: Corporate Microsystems, Inc. Lines: 58 Keywords: varargs References: I'm have a problem working with the standard *nix varargs construct. What I'm basically trying to do is implement two levels of variable argument passing, similar to what the vprintf() routine must be doing. Now, I don't have the sources to vprintf, and I don't know if it can be done portably in the context of the varargs guidelines. 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 first routine to get called, which works fine, looks like this: myprintf(fmt, va_alist) char *fmt; va_dcl { va_list vap; va_start(vap); /* here I can pull of the arguments with no problem */ myfprintf(stdout,fmt,vap); va_end(vap); } Here's what I've tried, which doesn't work, for myfprintf(): myfprintf(f, fmt, va_alist) FILE *f; char *fmt; va_dcl { va_list vap; va_start(vap); /* at this point, the va_arg() routine doesn't return the arguments correctly */ va_end(vap) } Is there anyone out there who has a good handle on varargs that can tell me the right (portable) way to do this? Is there someone with the source to vprintf() with some insight? Thanks, Theo Pozzy, Corporate Microsystems, Inc. ...!decvax!dartvax!eleazar!cmi (UUCP) cmi@eleazar.dartmouth (CSNET) cmi%eleazar@dartmouth.edu (ARPA) Box A-58, Hanover, NH, 03755 (USPS) CompuServe (76267,413) (603) 448-5193 (BellNet) -- Theo Pozzy, Corporate Microsystems, Inc. ...!decvax!dartvax!eleazar!cmi (UUCP) cmi@eleazar.dartmouth (CSNET) cmi%eleazar@dartmouth.edu (ARPA) Box A-58, Hanover, NH, 03755 (USPS) CompuServe (76267,413) (603) 448-5193 (BellNet)