4.3 curses - how to discard "premature" input?

Guy Harris guy at auspex.UUCP
Sun Feb 19 05:05:29 AEST 1989


> Have you tried flushing the input buffer? Under MSDOS, it would be
>something like fflush(stdin); to remove unwanted characters in the
>input buffer.

Unfortunately, he's doing that stuff under UNIX, not MS-DOS, and:

	1) "fflush" on an input stream, on some UNIX C implementations,
	   doesn't do a damn thing; the May 13, 1988 dpANS indicates that the
	   action of "fflush" on something other than "an output stream
	   or an update stream in which the most recent operation was
	   output" is undefined.  (It appears to do what you want in
	   the S5R3 implementation - it throws away the stuff in the
	   input buffer.  It does the same in the SunOS 4.0
	   implementation.  It does not, however, do so in the 4.3BSD
	   implementation.)

	2) Tere's more than one input buffer that he'd want to flush. 
	   There's the one maintained by standard I/O; there's also the
	   one maintained by the terminal driver software, and flushing
	   the latter one requires that you perform an "ioctl" function
	   specific to terminals.  The standard I/O library doesn't
	   perform that function.



More information about the Comp.lang.c mailing list