Keyboard input/Flush the keyboard buffer: Difference between revisions

Line 827:
fseek(stdin, 0, SEEK_END);
 
// BTW, aA very dirty solution is below - an unbuffered stream does not need any flushing.
// any flushing etc. It should be safe - i.e. if called before any I/O then
// no trace of buffered characters remain in RAM. Use with care.
//
// setvbuf(stdin, NULL, _IONBF, 0);
 
// Now we are able to check if the buffer is really empty.
// BTW, NEVER use gets due to possible the buffer overrun.
//
fgets(text, sizeof(text), stdin);