Re: scanf behaviour



Ian Collins said:

Add

fflush( stdin );

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

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
.



Relevant Pages

  • Re: scanf(), ungetc() behaviour.
    ... Are you saying that my coding habit is lack of whitespace? ... The fflush() function is not defined for input streams, ... i just keep on seeing examples that uses fflush(stdin) ... and sscanf() in cases like this one. ...
    (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(), ungetc() behaviour.
    ... snip ... ... i just keep on seeing examples that uses fflush(stdin) ... If your book uses void mainand fflushthen ...
    (comp.lang.c)
  • Re: Problem using fseek
    ... to fflush() invokes undefined behavior. ... implementations may choose to define the behavior. ... fflush does not function on stdin. ...
    (comp.lang.c)
  • Re: scanf(), ungetc() behaviour.
    ... snip ... ... void mainand fflush(stdin):( ...
    (comp.lang.c)