Re: how to check the scanf function if it will read more than one number



Moosdau wrote:
Peter Nilsson wrote:

Your implementation probably defines a behaviour fflush on input streams. It would do so as an extension. That extension is not topical in comp.lang.c.

it do be that. I think I've already known the answer. the below
is I copied from MSDN:

The fflush function flushes a stream. If the file associated
with stream is open for output, fflush writes to that file the
contents of the buffer associated with the stream. If the stream
is open for input, fflush clears the contents of the buffer.

Which is typical of Microsoft ignoring standards. They encourage people to write non-standard code, which is then tied to their own systems, and thus increases their income.


For general systems where what, if anything, functions as an input mechanism is not defined, the C language has no control. There is no way it can possibly anticipate the arrival of input. Thus input routines, when called, have to await actual input before returning. There may not be any input buffer, and if there is there is no defined way of interrogating it for non-emptyness. Thus the language cannot insist on fflush functioning on input streams, and any attempt to so do makes the program non-portable.

--
"If you want to post a followup via groups.google.com, don't use
 the broken "Reply" link at the bottom of the article.  Click on
 "show options" at the top of the article, then click on the
 "Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
.



Relevant Pages

  • Re: how to check the scanf function if it will read more than one number
    ... It would do so as an extension. ... > The fflush function flushes a stream. ... > the buffer associated with the stream. ...
    (comp.lang.c)
  • Re: scanf(), ungetc() behaviour.
    ... Please don't snip attributions for material you quote. ... If stream points to an output stream or an update ... fflush function causes any unwritten data for that stream to ...
    (comp.lang.c)
  • Re: Puzzle!
    ... If stream points to an output stream or an update ... fflush function causes any unwritten data for that stream to ... In this International Standard, ``shall'' is to be ...
    (comp.lang.c)
  • Re: scanf behaviour
    ... 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 ... the most recent operation was output, the fflush function causes any ...
    (comp.lang.c)
  • Re: I/O buffering
    ... StreamReader also buffers data? ... so they buffer as well. ... Neither StreamReader nor StreamWriter inherit from FileStream. ... What StreamReader and StreamWriter _do_ use is any Stream instance. ...
    (microsoft.public.dotnet.languages.csharp)