Is there a way to check if there is something in cin? I tried peek (), but if there is nothing peek () is waiting for input, and that is not what I want. Thanks you
You cannot use cin to read keystrokes, and then continue to do something else if there is nothing available, and I think you might want to. cin is a buffer stream and just doesn't work that way. In fact, there is no way to do this using standard C ++ - you will have to use OS-specific functions.
C ++ streams and streambufs are synchronous, meaning they are blocked until there is enough input to read. There is no portable way to check a stream asynchronously. Consider calling peek () from a separate thread.