rds95@leah.Albany.Edu (Robert Seals) (04/15/88)
I know it's not strictly C, but it IS the secondary group... 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)' ??? Is this dopey? Am I a buffoon? Do I have to do it myself for goodness sake? oomingmak and all that, rob If `reply' doesn't work, try rob@asrcmv.albany.edu or rds95@leah.albany.edu Failure to do so will result in the failure
sam@ncsuvx.ncsu.edu (Samuel A. Moore) (04/16/88)
In article <686@leah.Albany.Edu> rds95@leah.Albany.Edu (Robert Seals) writes: > >Has anybody got any great ideas about how to formatted text output >on the graphics screen, i.e., `gprintf(format, arg, ..., arg)' ??? Try sprintf() to format the string and then use your string output function. Sam -- Sam Moore ||\\ || //==\\ //==\\ || || NCSU Computing Center || \\ || || ||==\\ || || Raleigh, NC || \\|| || || || || sam@ncsuvx.ncsu.edu || \\ \\==// \\==|| \\==//
swarbric@tramp.Colorado.EDU (Frank Swarbrick) (04/17/88)
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)' ??? Try... { char str[80]; sprintf(str,"Here is %d line",1); outtextxy(1,1,(char far *)str); } Frank Swarbrick (and his cat) swarbric@tramp.UUCP swarbric@tramp.Colorado.EDU ...!{ncar|nbires}!boulder!tramp!swarbric Mal and N*va are dead...
john@tifsie.UUCP (John Maline) (04/18/88)
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
Devin_E_Ben-Hur@cup.portal.com (04/18/88)
#include <stdarg.h>
#include <graphics.h>
#include <stdio.h>
int gprintf(char *format, ...)
{
char buf[81];
int ret;
va_list args;
va_start(args,format);
ret = vsprintf(buf,format,args);
outtext(buf);
va_end(args);
return ret;
}
chris@mimsy.UUCP (Chris Torek) (04/21/88)
In article <4576@cup.portal.com> Devin_E_Ben-Hur@cup.portal.com writes: >int gprintf(char *format, ...) { > char buf[81]; ... > ret = vsprintf(buf,format,args); > outtext(buf); I thought we just finished arguing over why `sprintf' is evil :-) . Note that this limits you to printing 80 characters or less. If you had a function-style stdio, you could do this: #include <stdio.h> #include <stdarg.h> /* etc */ #define GP_BUFSIZE 80 /* or whatever */ static int gwrite(void *context, const char *buf, int n) { char *realbuf = (char *)context; int k, left = n; while (left > 0) { k = left > GP_BUFSIZE ? GP_BUFSIZE : left; (void) memmove((void *)realbuf, (void *)buf, k); realbuf[k] = 0; outtext(realbuf); buf += k; left -= k; } return (n); } int gprintf(char *fmt, ...) { FILE *fp; va_list ap; int rv; char buf[GP_BUFSIZE + 1]; /* leave room for '\0'! */ if ((fp = fwopen((void *)buf, gwrite)) == NULL) return (-1); va_start(ap, fmt); rv = vfprintf(fp, fmt, ap); va_end(ap); (void) fclose(fp); return (rv); } A bit clumsy, I admit, but this has no output restrictions. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris