getch() in c

Discussion in 'C Programming' started by lior l, Aug 13, 2003.

  1. lior l

    lior l Guest

    Hello,
    I am looking for a C function that works just like getch() in C++,
    meaning I want the computer to wait for a one byte input and continue
    (without pressing on the enter key). I have tryied "curses.h"
    "ctype.h" but it doesn't work properly on Xterm.

    thank you,
    Lior
     
    lior l, Aug 13, 2003
    #1
    1. Advertisements

  2. lior l

    Richard Bos Guest

    AFAIK there is no such thing in C++, either. In any case, for C, you
    really do want to read the FAQ:
    <http://www.eskimo.com/~scs/C-faq/q19.1.html>.

    Richard
     
    Richard Bos, Aug 13, 2003
    #2
    1. Advertisements

  3. lior l

    Greg P. Guest

    | Hello,
    | I am looking for a C function that works just like getch() in C++,
    | meaning I want the computer to wait for a one byte input and continue
    | (without pressing on the enter key). I have tryied "curses.h"
    | "ctype.h" but it doesn't work properly on Xterm.

    There is no standard way to do this. It deals with your terminal's setting
    (which can be different between systems, and thus is not supported by the
    ANSI/ISO C standard). I think there is something about this in this
    newsgroup's FAQ: http://www.eskimo.com/~scs/C-faq/top.html Just do a search
    for what you are looking for (via your browser)
     
    Greg P., Aug 13, 2003
    #3
  4. lior l

    Malcolm Guest

    ctype.h is a standard header giving information about character types (is a
    character whitespace, is it a digit, etc). This has nothing to do with
    finding a getch().
    I'm surprised that curses.h doesn't work on your X system, and I would guess
    that you have failed to initialise the curses system properly. However it is
    not part of ANSI C so I can't go into too much detail here.
     
    Malcolm, Aug 13, 2003
    #4

  5. Hi,

    afaik, getch() is a function from conio.h, a non-standard header for
    DOS/Windows compilers. I'm pretty sure there is no function like this
    defined in C99.

    Fabian
     
    Fabian Bornhofen, Aug 13, 2003
    #5
  6. lior l

    Programming Guru

    Joined:
    Oct 5, 2011
    Messages:
    1
    Likes Received:
    0
    Answer

    Hi Friend simple answer is use <conio.h>
     
    Programming Guru, Oct 5, 2011
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.