I am writing a snake program for my programming class in C. I was thinking about how to implement input from user but i have some difficulties. When the game starts i want to wait 1 second for the user to enter an arrow key ( for the direction ) , if he doesnt enter anything just continue.
I cant use scanf, getchar because they block. I tried using select to keep an eye on stdin but they dont trigger unless a character is followed by the return key.
I know by working with the shell that characters get buffered if they dont appear on the screen ( lets say if u got a search going on and start pressing buttons ). So is there a buffer for those characters, if so could you point me to a text that explains how to deal with it ?
Can you guys plz help me ?
Thank you very much in advance.