Unbuffered I/O using MicroSoft C 3.0

Larry Lippman larry at kitty.UUCP
Sat Jan 10 02:40:49 AEST 1987


In article <1867 at sunybcs.UUCP>, ugwayne at sunybcs (Wayne Nelligan) writes:
>     A friend of mine recently asked me "If I knew of a program that would let
> your printer act like a typewriter?".  Since a program of this sort seemed 
> really easy to write (just get characters and send them to the printer), I
> decided I would just write one myself.  Well, I am sorry to say, things have
> not been as easy as I thought they would be.  The problem is that I can't get
> the printer to just print one character at a time.  It only prints out a line
> at a time.
>     I am using MicroSoft C 3.0 and I have tried various methods but each time
> the printer only prints out when I enter a Carriage Return.
> [further discussion of C I/O functions]

	The problem you relate has nothing to do with C programming or the
nature of your operating system - it strictly pertains to the functional
characteristics of your printer.
	Many electromechanical printers using wire-matrices, bands, chains
printwheels, etc. can only print the line buffer all at once (this is an
inherent printer design characteristic).  Most "better-quality" printers
of the above genre will permit "overprinting" of a line; i.e., printing
a line buffer without advancing the paper.  Comparatively few printers
(that are also NOT KSR terminals) will truly print one character at a time.
	To cite a few examples from looking around my lab:

1.	AT&T/Teletype 40P202 (132 col 300 lpm chain printer):
	<CR> prints the line buffer without advancing the paper
	<NL> prints the line buffer with advancing the paper
	NO single-character printing

2.	Okidata Microline 82A (120 cps wire-matrix printer):
	<CR> prints the line buffer with advancing the paper
	<NL> advances the paper one line but prints nothing
	NO single-character printing

3.	Centronics Horizon H136A (120 cps wire-matrix printer):
	<CR> prints the line buffer without advancing the paper, provided
		that an option switch is set to disable paper advance on <CR>
	<NL> prints the line buffer with advancing the paper
	NO single-character printing

3.	Centronics 703 (120 cps wire-matrix printer):
	<CR> prints the line buffer without advancing the paper
	<NL> advances the paper one line but prints nothing
	NO single-character printing

	Note the different characteristics of the above printers.  By far,
the Okidata is the "cheapest" of the above printers, and there just ain't no
way to get it to print other than a whole line along with advancing the paper.
	Now you should see where your problem lies.  There may be a way
around the problem under some circumstances - keep overprinting, with each
successive overprint using space characters to force the desired character
into proper position.  However, this does seem to be rather extreme.
	There is an important moral to what may seem like a trivial
discussion:  Depending upon your printer and its configuration, simple C
statements directing output to a printer (i.e., though a stream defined
as a printer using fputc, fputs, fprintf, etc.) may NOT do what you think
they should!

<>  Larry Lippman @ Recognition Research Corp., Clarence, New York
<>  UUCP:  {allegra|bbncca|decvax|nike|rocksanne|watmath}!sunybcs!kitty!larry
<>  VOICE: 716/688-1231        {hplabs|ihnp4|mtune|seismo|utzoo}!/
<>  FAX:   716/741-9635 {G1,G2,G3 modes}    "Have you hugged your cat today?" 



More information about the Comp.lang.c mailing list