Wrapper function to sprintf
Romain Kang
romain at pyrnj.uucp
Thu Mar 3 13:47:16 AEST 1988
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 <varargs.h>
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
More information about the Comp.sys.pyramid
mailing list