Console application.
There is a cycle, in it 3 class methods are called in turn. It is necessary that when you press a button from the keyboard (for example, 'A'), the cycle stops, with the possibility of continuing on the button (for example, 'S').
- 'There is a cycle' - if it is, it would be good to add it to the question. - koks_rs
|
3 answers
For example, something like this:
char c; while(1) { ... if(kbhit()) // если была нажата какая-нибудь клавиша { if((c=getch())=='A') // если это буква 'A' { while(getch()!='S'); // то висеть на ф-ии приёма символа, пока он не будет равен 'S' } } } - thanks, what you need - nueq
- @nueq I don’t understand how this answer differs from Harry’s? - Mikhailo
- @Mikhailo is no different at all. just while I was writing my answer for a long time, Harry managed to write his own. - Edward
|
It might look something like this:
volatile bool pauseCondition = false; while (true) { while (pauseCondition) sleep(100); doPayloadIteration(); } In the meantime, another thread that handles user input can affect the pauseCondition .
|
Something like
for(...) { ....... // Бурная деятельность if (kbhit()) { char c = getch(); if (c == 'A') { while(getch() != 'S'); } } } not satisfied? ... Or I misunderstood the question?
|