GithubHelp home page GithubHelp logo

Comments (4)

johnwcowan avatar johnwcowan commented on June 3, 2024

There is absolutely no ISO C or Posix way to do this.

On Windows, fflush(stdin) works.

On Linux and *BSD, fpurge(stdin) works.

On Solaris, _fpurge(stdin) works: note leading underscore.

Note that this flushes only the contents of the process's own stdio buffer; it does not affect characters still living in a kernel buffer.

from medley.

masinter avatar masinter commented on June 3, 2024
grep -r fflush'(stdin)' src inc
src/dbgtool.c:    fflush(stdin);                                            \
src/dbgtool.c:    fflush(stdin);                                \
src/dbgtool.c:        fflush(stdin);
src/testtool.c:    fflush(stdin);                                   \
src/common.c:  fflush(stdin);
src/common.c:    fflush(stdin);
src/uraid.c:      fflush(stdin);
src/uraid.c:          fflush(stdin);
src/uraid.c:      fflush(stdin);
src/uraid.c:      fflush(stdin);

so not so important; not clear to me what bad thing will happen if fflush(stdin) doesn't do anything.

from medley.

johnwcowan avatar johnwcowan commented on June 3, 2024

from medley.

nbriggs avatar nbriggs commented on June 3, 2024

... because it's about to drop into its internal debugger and read input that the user was not expecting, so it wants to flush the input buffer and ensure that it is not reading typeahead.

from medley.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.