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

James E. Prior jep at oink.UUCP
Wed May 25 09:54:29 AEST 1988


In article <242 at tahoma.UUCP> jwf0978 at tahoma.UUCP (John W. Fawcett) writes:
>I have what may actually be a simple question, but I could not find an
>answer in my K & R.  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.  Any help out there?  
>
>			    Thanks,
>			    John
>
>John W. Fawcett		      Voice: (206) 237-2564
>Boeing Commercial Airplanes   UUCP: ..!uw-beaver!ssc-vax!shuksan!tahoma!jwf0978

printf() is pretty simple.  It is so simple that it doesn't know or care 
what column you're at on a line.

The following trick, albeit ugly, might work:

   printf("...\r%*s...",...,width,"",...);

I admit to not having tried it.  If it works, but it still too ugly,
or unsuitable due to the overprinting, you'll probably have to resort
to something else than printf().

Good luck,
-- 
Jim Prior    {ihnp4|osu-cis}!n8emr!oink!jep    jep at oink.UUCP

Pointers are my friend.



More information about the Comp.lang.c mailing list