Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!watmath!sunybcs!ugwayne
From: ugwayne@sunybcs.UUCP
Newsgroups: comp.lang.c,comp.sys.ibm.pc
Subject: Unbuffered I/O using MicroSoft C 3.0
Message-ID: <1867@sunybcs.UUCP>
Date: Fri, 9-Jan-87 02:37:29 EST
Article-I.D.: sunybcs.1867
Posted: Fri Jan  9 02:37:29 1987
Date-Received: Fri, 9-Jan-87 21:30:55 EST
Sender: nobody@sunybcs.UUCP
Reply-To: ugwayne@sunybcs.UUCP (Wayne Nelligan)
Organization: SUNY/Buffalo Computer Science
Lines: 51
Xref: watmath comp.lang.c:633 comp.sys.ibm.pc:788



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@Buffalo.CSNET
ARPANET:  ugwayne%Buffalo@csnet-relay.ARPA
BITNET:   ugwayne@sunybcs.BITNET