Path: utzoo!attcan!uunet!husc6!purdue!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: How do I get printf to move to a tab position? Keywords: printf, tab, overwrite Message-ID: <11710@mimsy.UUCP> Date: 28 May 88 18:30:34 GMT References: <242@tahoma.UUCP> <284@dcscg1.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 50 In article <284@dcscg1.UUCP> cpp90221@dcscg1.UUCP (Duane L. Rezac) writes: >(If someone knows a better way to do this, Please post it. ... Okay: >printl(x,y,control,args) >unsigned char *control; >unsigned args; >int x,y; >{ > printf("\33[%d;%dH",x,y); /* prints ansi cursor movement command to stdout*/ > printf(control,args); /* print data */ >} x and y are actually used as row and column respectively; so this should be `y, x' or `row, col'. In addition, you should use `vprintf' if you have it, so as to have the correct types and number of arguments at all times. Also, the control (format) argument should be `char *'. #include #include int #ifdef __STDC__ rcprint(int row, int col, char *fmt, ...) /* dpANS */ #else rcprint(va_alist) /* K&R &/ va_dcl #endif { int nchars; va_list ap; #ifndef __STDC__ int row, col; /* K&R */ char *fmt; va_start(ap); row = va_arg(ap, int); col = va_arg(ap, int); fmt = va_arg(ap, char *); #else va_start(ap, fmt); /* dpANS */ #endif nchars = vprintf(fmt, ap); /* both */ va_end(ap); return (ferror(stdout) ? EOF : nchars); } -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris