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. Advertising

  2. lior l

    Richard Bos Guest

    (lior l) wrote:

    > 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).


    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. Advertising

  3. lior l

    Greg P. Guest

    "lior l" <> wrote in message
    news:...
    | 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

    "lior l" <> wrote in message
    >
    > I have tryied "curses.h" "ctype.h" but it doesn't work properly on
    > Xterm.
    >

    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. lior l wrote:
    > 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



    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
    Answer

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

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. azsx

    getch in Java

    azsx, May 3, 2006, in forum: Java
    Replies:
    5
    Views:
    9,479
  2. Matthew
    Replies:
    0
    Views:
    2,908
    Matthew
    Jun 28, 2003
  3. voidstar
    Replies:
    3
    Views:
    10,103
    Mark R Rivet
    Jul 27, 2004
  4. Shugong Wang
    Replies:
    2
    Views:
    9,625
    Raymond Martineau
    Nov 28, 2004
  5. aurgathor
    Replies:
    4
    Views:
    7,945
    Karl Heinz Buchegger
    Mar 16, 2005
Loading...

Share This Page