Why doesn't getch() read the last character entered?
问题 I am writing a snake game in C using the ncurses library, where the screen updates itself every second. As those who have played the game will know, if the user enters various keys or holds down a key for long, there should be no 'buffered' key presses which get stored. In other words, if I hold down w (the up key) and stdin receives a sequence of 20 w s, and subsequently enter a d (the right key), I expect the snake to immediately move to the right, and ignore the buffered w s. I am trying