I only want the program to quit if the user has hit a key and that key corresponds to the ESC key. Otherwise i want it to continue looping.
This is easlily done in windows(shows below), but is there a function which checks for a key press using linux?
thanksCode:#include <stdio.h> #include <conio.h> #define ESCAPE 27 int main(void) { int loop = 0; int c; while(!loop) { printf("\tIM IN THE LOOPY\n"); if ( kbhit()) { c = getch(); if ( c == ESCAPE ) { printf("YOU HIT ESCAPE...NOW QUITTING"); loop = 1; } } } }



LinkBack URL
About LinkBacks


