Answer the question
In order to leave comments, you need to log in
C++ How to make permanent output, and only then, user something to execute input in a loop?
C++ How to make permanent output, and only then, user something to execute input in a loop?
Even simpler, the loop outputs something without paying attention to _gectch(), but as soon as the user enters some character, it accepts it and outputs it.
Answer the question
In order to leave comments, you need to log in
You did not specify an operating system. If you have linux (or something similar) - here is a solution using select .
In general, you can start a separate thread that loops what you want and checks if the event ( WaitForSingleObject , with timeout 0) has been set. In the main thread, create an event ( CreateEvent ), wait as usual for _getch, when the character is entered - use SetEvent to signal this to the second thread, there is also a ResetEvent function - to reset the event after processing (so that you can loop after the next character entered again install). This is for windows.
Well, yes, _getch is never C ++, but bare C.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question