C problems
08-Mar-91 02:09:00
Sb: #8189-C problems
Fm: Greg Comeau@Comeau Cmptg 72331,3421
To: Robert Hayes 70431,1737
>or do the dreaded unbuffered input routine
And what would that be? Don't Ami C compiler support setbuf/setvbuf()??
>Of course "there should be a call to fflush() between input and output
>calls. The call ensure that any input or output collected in
>intermediate buffers is sent on…" This is a direct quote from my >C
manual.
Your C manual is wrong from both a C standard perspective and a logistic
one (input buffers can't be "sent on", that makes no sense). A direct
quote from ANSI C tell us:
"If 'stream' points to an output stream or an update stream in which the
most recent operation was not input, the fflush function causes any
unwritten date for that stream to be delivered to the host environment to
be written to the file; otherwise, the behavior is undefined."
So like I said earlier, fflush() is for output even though many C compiler
do support fflush()ing input streams. Why standard doesn't allow the input
stream this capabilility is because the fflush() can become quite futile
given that the host environment has input mechanisms that occur before that
hit into the stdio subsytem with the effect that the fflush() becomes
innocuous in some cases and logically detrimental in other cases.