getch() equilvalent in Linux

This is a discussion on getch() equilvalent in Linux within the C++ Programming forums, part of the General Programming Boards category; I want to make code that will run portably under Linux, but unfortunately it does not like conio (non-portable). But, ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    155

    getch() equilvalent in Linux

    I want to make code that will run portably under Linux, but unfortunately it does not like conio (non-portable). But, is there another, easier way to do getch() that is portable?

  2. #2
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    How about:

    int fgetc(FILE *stream)
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    155
    FILE * stream?

  4. #4
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    if you're reading from keyboard use fgetc(stdin)
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  5. #5
    moi
    moi is offline
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    Originally posted by Cshot
    How about:

    int fgetc(FILE *stream)
    fgetc() is not like getch(), the big difference being line buffered
    hello, internet!

  6. #6
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    Oops. I thought he said getchar.
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  7. #7
    Registered User
    Join Date
    Oct 2002
    Posts
    155
    What about plain ol getch()?

  8. #8
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    Most linux systems support the getch function. It's located in the curses library

  9. #9
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    vVv, you're absolutely right about the FAQ thing and the portability of the curses library. I only wanted to inform Nakeerb about the getch function in the curses library.

    Why don't you send a PM to kermi3 about the getch issue? I'm sure he can add it to the FAQ.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to use getch in Linux?
    By blondie.365 in forum C Programming
    Replies: 6
    Last Post: 10-22-2008, 03:58 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 02:01 AM
  3. Pls repair my basketball program
    By death_messiah12 in forum C++ Programming
    Replies: 10
    Last Post: 12-11-2006, 05:15 AM
  4. installing linux for the first time
    By Micko in forum Tech Board
    Replies: 9
    Last Post: 12-06-2004, 05:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21