I've just heard about _kbhit() and I don't know how to use it the right way. How I should write my code to show something on the screen every time the keyboard is hit?
It will show "KEYBOARD HIT" forever, and I just want it to show one time, and then to be needed to press a key again to show "KEYBOARD HIT".
What can I do?
PS: I'm using CodeBlocks
The while(1==1) part of the loop involves a condition 1 == 1 which is always true. You have created an infinite loop.
Maybe scrap conio.h and use getchar() or a similar function including a clear/no tricks condition would be a better strategy. Try some of the tutorials / reference material here.
PS Take comfort that Codeblocks is not the problem.
The non-standard _kbhit() function doesn't remove any characters from the input buffer it just detects if there is a character in the buffer. If you don't remove the character then _kbhit() continue to detect the character.