Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!pegasus!hansen From: hansen@pegasus.UUCP Newsgroups: comp.lang.c Subject: Re: using varargs function to call another varargs function Message-ID: <3004@pegasus.UUCP> Date: Wed, 8-Jul-87 23:50:31 EDT Article-I.D.: pegasus.3004 Posted: Wed Jul 8 23:50:31 1987 Date-Received: Sat, 11-Jul-87 15:27:18 EDT References: <1332@rosevax.Rosemount.COM> Reply-To: hansen@pegasus.UUCP (60021254-Tony L. Hansen;LZ 3B-315;6243) Distribution: world Organization: AT&T Information Systems, Lincroft, NJ Lines: 58 Keywords: curses, System Vr3, vwprintw(), vwscanw() Summary: Vr3 curses makes this easy with vwprintw The UNIX System V release 3 version of the curses library makes writing functions such as this much easier by providing the vwprintw() function. From the Vr3 curses man page: vwprintw(win, fmt, varglist) WINDOW *win; char *fmt; va_list varglist; This routine corresponds to vfprintf(3S). It performs a wprintw() using a variable argument list. The third argument is a va_list, a pointer to a list of arguments, as defined in. See the vprintf(3S) and varargs(5) manual pages for a detailed description on how to use variable argument lists. Your dprintf function now becomes: #include #include WINDOW *window1; dprintf(va_alist) va_dcl { int a,b; char *s; va_list ap; va_start(ap); a = va_arg(ap, int); b = va_arg(ap, int); s = va_arg(ap, char*); wmove(window1, a, b); vwprintw(window1, s, va_alist); va_end(ap); } (Note how the arguments are pulled off the stack rather than being declared as parameters. The way you had it is non-portable using . See the varargs man page for more info on using varargs.) There is also a corresponding vwscanw() function for doing input. If you don't have the System V release 3 version of curses, you should look into using the vsprintf() function which has been mandated as part of the dpANS C standard. Using this function, you can replace the above vwprintw() statement with: char buf[BUFSIZ]; vsprintf(buf, s, va_alist); wprintw(window1, "%s", buf); If you don't have vsprintf(), complain to your C vendor. There have been several public domain versions posted in the past. Tony Hansen ihnp4!pegasus!hansen