kbhit() is detcted as a variable

+2 votes
asked Apr 8, 2019 by Phillip Brändle (160 points)
So I want to programm snake and fo that I tried to use kbhit() from the conio.h Library but it doesnt work. It's detected as a variable and therefor gives an error. Can anyone tell me why that is or give me an alternitive way of detecting wheather a key is hit?

1 Answer

0 votes
answered Apr 10, 2019 by Tommy Shaw (140 points)

conio.h isn't included in the c/c++ standard, and it's also not included in gdb's supported third party libraries(https://www.onlinegdb.com/faq) so you won't be able to use it on here (I don't think.) As far as alternatives I couldn't really think of/find anything that would be comparable. Good luck though!

commented Apr 10, 2019 by Mohit Basliyal
This function is not defined as part of the ANSI C/C++ standard. It is generally used by Borland's family of compilers. It returns a non-zero integer if a key is in the keyboard buffer. It will not wait for a key to be pressed.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...