c++ - Clear buffer independent of the operating system -


i'd know how can clear standard input buffer, regardless of operating system i'm using. know in windows can use fflush , linux fpurge, single solution works both (does not have function).

depending on mean "clear standard input buffer", may do:

int c; while ((c = getchar()) != eof && c != '\n') /* nothing */; 

this absorbs eof or newline, whichever comes first.

the main situation wouldn't want if don't want maybe block until user presses enter. in case, you're sol; there no universal mechanism.


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -