Thread: Using getch()

  1. #1
    Registered User
    Join Date
    May 2002

    Using getch()

    I am familiar with using getch() in a windows C compiler, but am having trouble while using it in gcc. I am attempting to use it to have my program wait for an enter keystroke, this is very easy to do in windows, all I need to do is include conio.h and add getch() to my code. In linux I did a 'man getch' and read that I must instead include curses.h, which I did. If I use getch() in my linux code I get quite a few errors. What can I use to have my program wait until it gets an enter keystroke?

  2. #2
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    What errors do you get?
    Compile errors (don't forget to include the curses library) or runtime errors?

  3. #3
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Bangalore, India
    How did you compile, did you include the curses library while compiling? Like:
    cc main.c -o main -lcurses
    Just including curses.h is not going to help you at all, you also need to link with the appropriate library, which in your case is the 'curses'.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. Pls repair my basketball program
    By death_messiah12 in forum C++ Programming
    Replies: 10
    Last Post: 12-11-2006, 05:15 AM
  3. Pause a C program without getch()
    By swgh in forum C Programming
    Replies: 4
    Last Post: 02-20-2006, 11:24 AM
  4. Clearing input buffer after using getch()
    By milkydoo in forum C++ Programming
    Replies: 3
    Last Post: 07-21-2003, 11:04 PM
  5. Problems with getch()
    By GrNxxDaY in forum C++ Programming
    Replies: 14
    Last Post: 08-12-2002, 02:11 AM