C++ cin keypress event
问题 I believe this is a very simple question, but I can't find a simple answer to it. I have an infinite loop, e.g. while(1) , for(;;) , and I need to break from the loop on a keypress. What is the easiest way to do this? P.S.: I can't use getch , cin.ignore , or cin.get because it stops the loop. 回答1: Well, what you want is asynchronous input. All of the methods provided by cin wait for enter. You will have to use system-specific functions for that, or use a library that will do it for you. What