sandra@utah-cs.UUCP (03/29/87)
I have been having some problems reading from the keyboard (CON:) in a manner consistent with the way one reads from ordinary files. I'm writing a program where I'd like to treat both keyboard and files as generic input streams: the user gives me a pathname and I read from it. But, I've discovered that the basic i/o functions behave differently depending on whether one is reading from the keyboard or a file. I first tried using the C library functions fopen and fgetc. These work just fine for files, as long as you remember to look for \r\n as an end-of-line marker instead of just \n. But, when reading from CON:, fgetc seems to buffer up everything I type until I type *two* carriage returns, and then after cleaning out the buffer, further calls to fgetc return EOF. I've also tried using Fopen and Fread. Again, no problems for files: Fread will fill up the buffer you supply, marking end-of-line as \r\n. Calling Fopen on "CON:" returned error -1. Calling Fread with handle 1 (which is supposed to correspond to CON:) results in different behavior: it seems to ignore carriage returns, but when I type a linefeed, it immediately returns with whatever characters are in the buffer, but *without* an end-of-line marker! Do I have to write my own i/o library so that my program can treat CON: like any other input stream? Has anybody already done so, or found some other workaround for these problems? -Sandra Loosemore sandra@utah-cs.uucp, sandra@cs.utah.edu