Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!elroy.jpl.nasa.gov!cit-vax!bek-owl!mazer From: mazer@bek-owl.caltech.edu (Jamie Mazer) Newsgroups: comp.unix.wizards Subject: varargs question Summary: va_alist Keywords: varargs vsprintf Message-ID: <11286@cit-vax.Caltech.Edu> Date: 15 Jul 89 23:38:55 GMT Sender: news@cit-vax.Caltech.Edu Reply-To: mazer@bek-owl.caltech.edu (Jamie Mazer) Distribution: usa Organization: California Institute of Technology Lines: 26 Recently, I have found I needed something like the C++ form function (I believe this came up pretty recently in another list as well). Our masscomp libs don't have vsprintf() etc, so as a kludge, I first tried to cobble something together along the lines of: format(a1, a2, a3, ... , a10) /* ugly, but it often works ;-) */ char *a1, *a2, *a3, ... , *a10) { ... sprintf(buf, a1, a2, a3, ... , a10); return(buf) ... } However, then someone suggested I try the following solution: format(va_alist) va_dcl { ... sprintf(buf, va_alist); return(buf); ... } The question is, is the second method a valid one? It seems to work on our SUNs, but not reliably on the Masscomp, though for the life of me, I can't figure out where and when it blows up. Is it legit to pass va_alist into another function like that? If so, then why are the vprintf() functions necessary at all? Thanks, /Jamie UUCP: {rutgers,ames}!cit-vax!bek-owl!mazer ARPA: mazer@bek-owl.caltech.edu "It's a fine line between line between BITNET: jmazer@caltech.bitnet clever and stupid" -- Spinal Tap