I am creating a console application in C. This is a game in which characters are falling down and user has to press that specific key on the keyboard. I don\'t know how to detec
There is a function called kbhit() or _kbhit it is in the library it returns true or false depending whether a key was hit. So you can go with something like this:
while (1){
if ( _kbhit() )
key_code = _getch();
// do stuff depending on key_code
else
continue;
Also use getch() or _getch which reads a character directly from the console and not from the buffer. You can read more about conio.h functions here they might be very useful for what you want to do.
Note: conio.h is not a standard library and implementations may vary from compiler to compiler.