-3

Hello There is a file where I draw picture using a loop. I want to exit loop when 'q' button is pressed. But I want the program is running during it is waiting 'q'. How to implement this behavior? I tried using system("stty -icanon min 1") but in this case program WAITS any char between loops. When ("stty -icanon min 0") the program doesn't read from stdin and terminal pushes all accumulated pressed buttons into stdout after finishing program Strings with loop in game.c file are: from 32 to 43. Thank in advance. Look at game.c file.

  • 1
    Please do not post links to external code but instead include the relevant code directly into the question. For this purpose there is no need to add all the game logic or UI drawing but just a minimum version focussing on your issue. See [MCVE](https://stackoverflow.com/help/mcve) for more information. – Gerhardh Apr 21 '22 at 05:48
  • Does this answer your question? [How to avoid pressing Enter with getchar() for reading a single character only?](https://stackoverflow.com/questions/1798511/how-to-avoid-pressing-enter-with-getchar-for-reading-a-single-character-only) – Allan Wind Apr 21 '22 at 06:49
  • `select()` could help you here. Or just interrupt the program with `^C` instead of `q` and catch the signal with `signal()` – Cosinus Apr 21 '22 at 07:36
  • "How to wait ... without waiting?" Perhaps the title is poorly worded, but this doesn't make much sense. – William Pursell Apr 25 '22 at 15:10

1 Answers1

0

termios + unistd libraries helped me.

2nd way is ncurses library with its embedded function of parallel input.