swagstaff
Posts: 1
Joined: Mon May 25, 2015 4:07 pm

Keyboard Interrupt on c++

Mon May 25, 2015 4:12 pm

I am wondering if there is a function similar to getchar() that does not stop my script from running until a key is pressed, but rather waits for the key in the background (such as an interrupt). The application is for ending an infinite loop. Thanks!

User avatar
mad-hatter
Posts: 419
Joined: Sun Feb 26, 2012 2:58 pm
Location: By the UK seaside

Re: Keyboard Interrupt on c++

Mon May 25, 2015 5:45 pm

Hello,

ctrl+c

Have a look here:-
https://www.google.co.uk/?gfe_rd=cr&ei= ... 20ctrl%2Bc

Regards

User avatar
AndyD
Posts: 2333
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: Keyboard Interrupt on c++

Mon May 25, 2015 8:53 pm

swagstaff wrote:I am wondering if there is a function similar to getchar() that does not stop my script from running until a key is pressed, but rather waits for the key in the background (such as an interrupt). The application is for ending an infinite loop. Thanks!
I have some code that is similar to getchar here.

Also, if you look at this thread, PeterO has some code that reads from /dev/input.

Return to “Beginners”