Unbuffered I/O using MicroSoft C 3.0
ugwayne at sunybcs.UUCP
ugwayne at sunybcs.UUCP
Fri Jan 9 17:37:29 AEST 1987
Subject: Unbuffered I/O using MicroSoft C Version 3.0
-----------------------------------------------------
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. At first, I was
using getc() and putc() and then it dawned on me that these functions
use buffered I/O. So I looked in the MicroSoft manuals and found the
function setbuf. I tried this on the stream stdprn and then ran the program
again. It still didn't work.
Next, I used the functions read() and write() which the manual states as
low-level I/O that do not buffer or format data. But again, the program
will not work the way I want it to. The Carriage Return is still needed to
start the print. Then, I thought that it might be that the printer was getting
the characters one at a time (so the pogram was working) and it may need a
Carriage Return before it does any printing (it had its own buffering).
With this in mind then I decided to just try my program with the standard
input and output devices. So when I hit a key, I would not only see my
keystroke but also another one which my program was then sending. This too,
did not work, a Carriage Return was still needed.
So what I would like to know then, Is how would I get a program like
this to work? How do you get unbuffered I/O using MicroSoft C 3.0?
What am I doing wrong? If anyone has any suggestions, I
would sure appreciate a response. This is really driving me crazy.
Thanks in advance,
Wayne
Wayne Nelligan
SUNY at Buffalo Computer Science
-------------------------------------------------------------------------
.{bbncca,decvax,dual,rocksvax,watmath,sbcs}!sunybcs!ugwayne
CSNET: ugwayne at Buffalo.CSNET
ARPANET: ugwayne%Buffalo at csnet-relay.ARPA
BITNET: ugwayne at sunybcs.BITNET
More information about the Comp.lang.c
mailing list