Jul 22, 2012 at 2:34am Jul 22, 2012 at 2:34am UTC
hi i want to write infinite loop which only terminates if the Ctrl-c is pressed from the keyboard.How do i use kbhit to do this?
Jul 22, 2012 at 4:54am Jul 22, 2012 at 4:54am UTC
Doesn't the console do that anyway on Ctrl-c ?
kbhit will only tell u if a key was hit. u'll need to call something like getch() to figure out what the key was immediately after kbhit returns nonzero
Jul 22, 2012 at 7:23am Jul 22, 2012 at 7:23am UTC
You should use signal() to catch Ctrl-c and Break.
Jul 22, 2012 at 9:55am Jul 22, 2012 at 9:55am UTC
use getch, and check if the result is the number 3