How do I get printf to move to a tab position?

Chris Torek chris at mimsy.UUCP
Fri May 20 00:28:23 AEST 1988


In article <242 at tahoma.UUCP> jwf0978 at tahoma.UUCP (John W. Fawcett) writes:
>... I would like to be able to tab over to a certain position on a
>line and place some text there without overwriting text that was
>already on the line, similar to the "X" format descriptor in FORTRAN.
>The closest I can come so far is to use a "%20s", but this overwrites
>whatever was there.

Do what FORTRAN does: print on a card punch or line printer.  Then
those pesky spaces will not overwrite the non-spaces. :-)

Seriously, most FORTRAN implementations have no idea how to back up;
they simply keep track of the current column, and when asked to get
to column 30 (via T, not X: X means blanks), print 30-current_column
blanks.  This approach works fine in C as well, but you have to count
the columns yourself.

Your operating system (which is not part of the C language) most
likely provides a higher-level screen management library, if you have
more ambition.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list