Interview Questions

How can I flush pending input so that a user ...

C Interview Questions and Answers


(Continued from previous question...)

How can I flush pending input so that a user ...

Q: How can I flush pending input so that a user's typeahead isn't read at the next prompt? Will fflush(stdin) work?

A:fflush is defined only for output streams. Since its definition of ``flush'' is to complete the writing of buffered characters (not to discard them), discarding unread input would not be an analogous meaning for fflush on input streams.

(Continued on next question...)

Other Interview Questions