[comp.sys.ibm.pc] Turbo C and cprintf

850181p@aucs.UUCP (STEVEN E. PARKER) (01/23/89)

  I seem to be having problems with Turbo C ver. 1.5 and its cprintf
routine. The \t (tab) seems to print funny faces instead of moving a
tab! I'm sorry if this has come up before. Thanks in advance.




-----------------------------------------------------------


Steven E. Parker Acadia Univ. School of Computer Science
Wolfville N.S. Canada BOP1XO
UUCP:      {uunet|watmath|utai|garfield}!dalcs!aucs!850181p
BITNET:    850181p@Acadia
Internet:  850181p%Acadia.BITNET@CUNYVM.CUNY.EDU


-----------------------------------------------------------

spolsky-joel@CS.YALE.EDU (Joel Spolsky) (01/29/89)

In article <1509@aucs.UUCP> 850181p@aucs.UUCP (STEVEN E. PARKER) writes:
>
>
>  I seem to be having problems with Turbo C ver. 1.5 and its cprintf
>routine. The \t (tab) seems to print funny faces instead of moving a
>tab! I'm sorry if this has come up before. Thanks in advance.
>

Sorry, you have to do it yourself. I know, that's a big
nuisance.

Try:

void tab()
{
	while ((wherex()-1) % 8)
		cprintf(" ");
}

+----------------+----------------------------------------------------------+
|  Joel Spolsky  | bitnet: spolsky@yalecs.bitnet     uucp: ...!yale!spolsky |
|                | internet: spolsky@cs.yale.edu     voicenet: 203-436-1483 |
+----------------+----------------------------------------------------------+
                                                      #include <disclaimer.h>

wales@valeria.cs.ucla.edu (Rich Wales) (02/08/89)

In article <49044@yale-celray.yale.UUCP> spolsky-joel@CS.YALE.EDU
(Joel Spolsky) proposes the following routine to substitute for the
inability of Turbo C 1.5 "cprintf" to handle tabs properly:

		void tab()
		{
			while ((wherex()-1) % 8)
				cprintf(" ");
		}

I believe there is a problem with this routine.  If the cursor is
already sitting on a tab stop, it won't print anything at all --
whereas the correct thing to do would be to print eight spaces.

How about the following alternative version?

		void tab()
		{
			cprintf(" ");
			while ((wherex()-1) % 8)
				cprintf(" ");
		}

The only difference is the addition of a "cprintf" before the "while".

-- Rich Wales // UCLA Computer Science Department // +1 (213) 825-5683
   3531 Boelter Hall // Los Angeles, California 90024-1596 // USA
   wales@CS.UCLA.EDU      ...!(uunet,ucbvax,rutgers)!cs.ucla.edu!wales
"The best diplomat I know is a fully charged phaser bank."