Subject: | |
From: | |
Reply To: | |
Date: | Fri, 9 Nov 2001 14:46:26 -0500 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Using getchar, scanf, and fgets on stdin will all be buffered unless you do
a setvbuf on it (which you must do before your first read).
Even if they are unbuffered, it won't generally terminate the read on Unix
systems or other systems running C programs. There isn't a portable way to
do it in C.
If you only want to do it on MPE, you can
char ca[2];
read(0, ca, 1)
which is unbuffered
You can also use READX from C. If you're using gcc, you need the longptr.h
header to deal with long pointers.
----- Original Message -----
From: "Barry Lake" <[log in to unmask]>
To: <[log in to unmask]>
Sent: Friday, November 09, 2001 1:55 PM
Subject: Re: c trivia
> At 10:40 -0800 11/9/01, John Burke wrote:
> >Is there a pure c way to duplicate n = readx(ca, -1)? I.E., depressing
any
> >key terminates the read. I've tried getchar and scanf to no avail. Both
seem
> >to require a return to terminate the read.
>
>
> Take a look at fgets().
>
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|
|
|