I want function that combines the functions kbhit() and getch().
In other words, I want when the program works, if I pressed on ‘q’ key the program stops without has stopped temporarily in order to receive the character as does getch() function .
I want to combine between kbhit() advantage and getch() advantage .
I hope you understood my purpose .
kbhittells you whether there’s a character waiting.getchwill return the next character, wiating for one if it needs to. The only natural combination of the two that I can think of is one that will return a character if there is one, but won’t wait if there isn’t a character available. That’s easy to do, given you already havekbhitandgetch: