-
Conio.h
Is there anyway to install this header on a generic GCC compiler? I need this header for some important lessons in my book, but my compiler lacks that header. Does anyone know a way I can get this working, or any different headers to use? I'm specifically using getche() and getch() right now. I realise that I can use getchar(), but I want to use them all. Thanks
-
nope unless you make your own getche with the help of terminos.h
Code:
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
int mygetch(void)
{
struct termios oldt,
newt;
int ch;
tcgetattr( STDIN_FILENO, &oldt );
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO );
tcsetattr( STDIN_FILENO, TCSANOW, &newt );
ch = getchar();
tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
return ch;
}
P.S. Always read the FAQ
-
I did read the faq, and right now that it just way too advanced for me. I haven't gotten that far at all. I just got into loops yesterday. I was just hoping there was a substitute header I could use.
-
if u r using linux then why dont u try typing "man getch" on the console. as far as i know getch is included in the curses.h library in linux.but i am not sure whether u can generally get characters or is it specific to the window though. why dont u give it a try though?
-
that would only work if he created a window you cannot use curses and getch like you would be able to in windows. I don't see what is so hard about that function instead of saying getch you would say mygetch and what the hay just change the name to getch and add it to the top of your code :D