PDA

View Full Version : Conio.h



ZakkWylde969
04-26-2004, 06:40 PM
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

linuxdude
04-26-2004, 08:38 PM
nope unless you make your own getche with the help of terminos.h


#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 (http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1042856625&id=1043284385)

ZakkWylde969
04-27-2004, 05:12 AM
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.

gooddevil
05-12-2004, 03:13 PM
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?

linuxdude
05-12-2004, 03:41 PM
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