🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc
Article #26498

Re: How about a `gprintf' for Turbo C

#26498
From: John Maline
Date: Sun, 17 Apr 1988 21:01
45 lines
2193 bytes
 Xref: tifsil comp.sys.ibm.pc:9083 comp.lang.c:6114
 
 In article <686@leah.Albany.Edu> rds95@leah.Albany.Edu (Robert Seals) writes:
>The new console functions in version 1.5 of turbo c are really swell
>and everything, (swollen too, if you check the size of the executable)
>but they aren't much good if you want to write on the graphics screen.
>Your only choice is `outtext{xy}', whose argument must be a string.
>
>Has anybody got any great ideas about how to formatted text output
>on the graphics screen, i.e., `gprintf(format, arg, ..., arg)' ???
How about this (appologies for source in this newsgroup... It's short)

#include <stdio.h>
#include <stdarg.h>

void gprintf(int x, int y, char *fmt, ...)
{
    va_list params;
    char    str[80];

    va_start(params,fmt);
    vsprintf(str,fmt,params);
    va_end(params);

    outtextxy(x,y,(char far *) str);
}

I may have left off a graphics library header here.  This is untested.
Don't forget to prototype it where used.
void gprintf(int x, int y, char *fmt, ...);
usage:  gprintf(1, 1, "Hi mom, i=%d", i);

No warranties, I speak only for myself, ...
(varargs disclaimer :-)               ^^^^^

John Maline                    UUCP:    ut-sally!im4u!ti-csl!tifsie!john 
Texas Instruments                          sun!texsun!ti-csl!tifsie!john
PO Box 655012  M/S 3618                   uiucdcs!convex!smu!tifsie!john
Dallas, TX 75265               Voice:   (214)995-3575      BIX: jwmaline
-- 
John Maline                    UUCP:    ut-sally!im4u!ti-csl!tifsie!john 
Texas Instruments                          sun!texsun!ti-csl!tifsie!john
PO Box 655012  M/S 3618                   uiucdcs!convex!smu!tifsie!john
Dallas, TX 75265               Voice:   (214)995-3575      BIX: jwmaline
Technical Details
Message-ID: <303@tifsie.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!mailrus!rutgers!bellcore!tness7!ninja!pollux!ti-csl!tifsie!john
References: <5443@sigi.Colorado.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!mailrus!rutgers!bellcore!tness7!ninja!pollux!ti-csl!tifsie!john
From: john@tifsie.UUCP (John Maline)
Newsgroups: comp.sys.ibm.pc
Subject: Re: How about a `gprintf' for Turbo C
Message-ID: <303@tifsie.UUCP>
Date: 17 Apr 88 21:01:25 GMT
References: <5443@sigi.Colorado.EDU>
Organization: TI Process Automation Center, Dallas Texas
Lines: 44