Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!pasteur!ucbvax!hplabs!pyramid!pyrnj!romain From: romain@pyrnj.uucp (Romain Kang) Newsgroups: comp.sys.pyramid Subject: Re: Wrapper function to sprintf Message-ID: <777@pyrnj.uucp> Date: 3 Mar 88 03:47:16 GMT References: <15847@pyramid.pyramid.com> Reply-To: romain@pyrnj.UUCP (Romain Kang) Organization: Pyramid Technology Corp, Woodbridge, NJ Lines: 31 Keywords: sprintf, wrapper, varargs varargs is indeed the correct solution, though the man page says nothing about nested variadic functions. This is probably trivial for comp.lang.c junkies, but it's still easy to use varargs non-portably. The correct translation of your function is #include dialog_box(cs, va_alist) char *cs; va_dcl { char buffer[512]; sprintf(buffer, cs, va_alist); . } However, it's easy to get wrong. The following doesn't look unreasonable -- it may even work on a VAX -- but probably fails on a Sun-3, which isn't such a radical box. It definitely doesn't work on a Pyramid... va_list ap; va_start(ap); sprintf(buffer, cs, ap); va_end(ap); -- Romain Kang {allegra,cmcl2,pyramid,rutgers}!pyrnj!romain Pyramid Technology Corp. / 10 Woodbridge Center. Dr / Woodbridge NJ 07095 "Eggheads unite! You have nothing to lose but your yolks!" -Adlai Stevenson