Troubleshooting kbhit() and control-C for Keyboard Input in Programming

  • Thread starter Thread starter timetraveldude
  • Start date Start date
Click For Summary
The issue arises when a program that waits for keyboard input encounters a Control-C command to exit, resulting in an error. This error likely occurs because the program exits before executing the code associated with detecting keyboard input through kbhit(). To resolve this, it is suggested to capture the Control-C escape sequence and implement a manual exit process. Additionally, the use of kbhit() is noted as it is a non-ANSI standard function, which may also contribute to compatibility issues.
timetraveldude
Messages
42
Reaction score
0
I have a programming running that waits for keyboard input. The problem is that when I press control-C to exit the program I get an error. I believe it is because the keyboard was pressed but the program is exiting before it can execute the code that is called when kbhit() is true. Any ideas.<br />
<br />
thanks.
 
Computer science news on Phys.org
thanks

thanks for the help.
 
Thread 'ChatGPT Examples, Good and Bad'
I've been experimenting with ChatGPT. Some results are good, some very very bad. I think examples can help expose the properties of this AI. Maybe you can post some of your favorite examples and tell us what they reveal about the properties of this AI. (I had problems with copy/paste of text and formatting, so I'm posting my examples as screen shots. That is a promising start. :smile: But then I provided values V=1, R1=1, R2=2, R3=3 and asked for the value of I. At first, it said...

Similar threads

  • · Replies 19 ·
Replies
19
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
392
  • · Replies 6 ·
Replies
6
Views
2K
Replies
12
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
11
Views
3K