Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!cmcl2!rna!rocky2!reintom From: reintom@rocky2.UUCP (Tom Reingold) Newsgroups: comp.lang.c,comp.sys.ibm.pc Subject: Re: Unbuffered I/O using MicroSoft C 3.0 Message-ID: <311@rocky2.UUCP> Date: Mon, 12-Jan-87 14:22:54 EST Article-I.D.: rocky2.311 Posted: Mon Jan 12 14:22:54 1987 Date-Received: Tue, 13-Jan-87 06:46:38 EST References: <1867@sunybcs.UUCP> Organization: Rockefeller Univ.,N.Y.C 10021 Lines: 57 Summary: Here is an even better example. Xref: mnetor comp.lang.c:673 comp.sys.ibm.pc:944 [] Ok, this program more closely addresses the problem you describe. As you can see, this small problem has been fun for me. ================================================================= #include#define CR '\r' #define LF '\n' #define SPACE ' ' #define ESC '\033' /* * This is an example program. It directly reads the keyboard * and prints to the standard printer, one character * at a time. Tabs and other subtle things will not work * because it is an example to show you that you can do * what you want to. * * The printer prints when the line length is reached or * when it gets a RETURN character. This program sends one * after each character. * * This program exits after the user presses ESCAPE. * */ main() { int i, linelen, c; linelen = 0; while ((c=getche()) != ESC) { fputc(c, stdprn); if (c != CR) { linelen++; fputc(CR, stdprn); for (i = 0; i < linelen; i++) fputc(SPACE, stdprn); fflush(stdprn); } else { linelen = 0; putchar(LF); fputc(LF, stdprn); fflush(stdprn); } } fputc(LF, stdprn); } -- Tom Reingold; The Rockefeller University; 1230 York Av; NY 10021 PHONE: (212) 570-7709 [office]; (212) 304-2504 [home] ARPANET: reintom@rockefeller.arpa BITNET: REINTOM@ROCKVAX UUCP: {seismo|ihnp4|yale|harvard|philabs|phri}!cmcl2!rna!rocky2!reintom