R
Richard Bos
Keith Thompson said:The Solaris version makes a fair amount of sense to me as well. C's
fflush() function doesn't *have* to follow the exact semantics of a
toilet.
Just as well; I wouldn't want my computer to sound like that every time
I write a line to a file.
In Solaris, fflush(stdin) discards any buffered input. If C defined a
discard_buffered_input() function, I don't think anyone would object
-- at least not on the same basis on which you object to
fflush(stdin).
Not entirely. However, I would still object, as I would also for
fflush(stdin), on the basis that discarding buffered input is not always
as easy as it seems. There's buffered and there's buffered; there are C
implementation buffers, and there are hardware buffers; IOW, it would
have to be quite strictly circumscribed to be implementable, and it's
not certain how useful such a limited flushing function would be.
Contrast this with an implementation-defined flushing function, which
can be useful for that implementation only, and ignore problems that
would occur on other hardware and/or OSes.
Richard