Thread: Conio.h

  1. #1
    ___
    Join Date
    Jun 2003
    Posts
    806

    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
    "When I die I want to pass peacefully in my sleep like my grandfather did, not screaming and yelling like the passengers in his car."

  2. #2
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    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

  3. #3
    ___
    Join Date
    Jun 2003
    Posts
    806
    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.
    "When I die I want to pass peacefully in my sleep like my grandfather did, not screaming and yelling like the passengers in his car."

  4. #4
    Registered User
    Join Date
    Apr 2004
    Posts
    58
    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?
    even a fish would not have been in danger had it kept its mouth shut.

  5. #5
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. conio.h not working in *nix
    By wise_ron in forum C Programming
    Replies: 2
    Last Post: 05-04-2006, 01:54 PM
  2. conio.h in Visual C++ ?
    By Born_2B_Alone in forum Windows Programming
    Replies: 3
    Last Post: 09-22-2004, 07:32 PM
  3. Getting textcolor in conio.h to work with Win32
    By MMD_Lynx in forum C Programming
    Replies: 5
    Last Post: 09-02-2004, 01:32 PM
  4. conio.h
    By Jaguar in forum Linux Programming
    Replies: 10
    Last Post: 10-17-2002, 01:12 AM
  5. Conio.h file problems
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 05-23-2002, 01:44 PM