lundi 30 mars 2015

How to abort getchar() command in C?

I am basically a beginner C++ programmer...and it's my first attempt to code in C.


I am trying to program a snake game (using system ("cls")).


In this program I need to get a character as an input (basically to let the user change the direction of movement of snake)... and if the use doesn't input any character within half a second then this character input command needs to be aborted and my remaining code should get executed.


Please give suggestions to sort out this problem.



EDIT: Thanks for the suggestions, but My main motive of asking this question was to find a method to abort the getchar command even if the user has not entered anything....Any suggestions on this? And by the way my platform is windows



Aucun commentaire:

Enregistrer un commentaire