So my teacher is having us use the cygwin gcc compiler to program things in c, but the gcc compiler doesn't have conio.h included in it nor does it seem to have curses.h. I am just wondering if there is a simple method to either create my own kbhit function or just include a specific header file other than the two I mentioned earlier. Thanks
Checking if a key is pressed using the gcc compiler in windows
Collapse
X
-
Tags: None
-
There is no standard way of replicating kbhit, getch, etc as the standard input functions are buffered and block while waiting on user input.
I remember reading an article somewhere where buffering could be turned off, but it's not portable. Try milling over the results from google and see if any will work for your situation.
Good luck -
Alright. I've been googling for about an hour so far with no luck as of yet. Thanks for the information though.Comment
-
So I figured out a way to do it.
Basically, making my own getch() function in which it calls a few system commands.
This is definitely not the way I would wish to perform this task, however, it works.Code:char getch(); char getch() { //Gets the raw input system( "stty raw" ); //Sets the buffer to not echo onto the screen system( "stty -echo" ); //gets the input char input = getchar(); //resets the input system( "stty cooked" ); //sets the buffer to echo system( "stty echo" ); return input; }Last edited by Rabbit; Nov 20 '14, 05:07 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.Comment
Comment