Re: scanf behaviour



I've tested "fflush( stdin );" on both WinXP and SunOS boxes it works
without a glitch.


stasgold@xxxxxxxxx wrote:
Thanks for reply.
I give it I try.
If this method is working only on flavours of unix , it's fine with me.

Ian Collins wrote:
Richard Heathfield wrote:
Ian Collins said:


Add

fflush( stdin );


No, don't do that. The behaviour of fflush on streams open for input is
undefined.

Oops, so it is.

I've always used the Solaris man page definition:

"If stream points to an input stream or an update stream into
which the most recent operation was input, that stream is
flushed if it is seekable and is not already at end-of-file."

--
Ian Collins.

.



Relevant Pages

  • Re: scanf behaviour
    ... Can Ian Collins can tell me were it is defined. ... Using http://www.freebsd.org/cgi/man.cgi we can see that fflush on input ... streams was defined with useful semantics in SunOS 4.1.3 (the earliest ... No flushing if the stream is not seekable (so not for a pipe, FIFO, socket ...
    (comp.lang.c)
  • Re: scanf behaviour
    ... Richard Heathfield wrote: ... U haven't provided any reference for your claim that fflush(stdin) is ... If stream points to an output stream or an update stream in which ...
    (comp.lang.c)
  • Re: scanf behaviour
    ... Ian Collins wrote: ... fflush(stdin); ... The behaviour of fflush on streams open for input is ... "If stream points to an input stream or an update stream into ...
    (comp.lang.c)
  • Re: scanf behaviour
    ... fflush(stdin); ... The behaviour of fflush on streams open for input is ... Oops, so it is. ... "If stream points to an input stream or an update stream into ...
    (comp.lang.c)
  • Re: need to convert a char to an hexadecmial value
    ... , to a newline character. ... Here's what the standard says: ... A text stream is an ordered sequence of characters composed into ... fflush() will cause a partial line to be written to the output file ...
    (comp.lang.c)