Results 1 to 4 of 4
  1. #1
    xr600
    Guest
    newbie Q - how to wait for keystroke in gcc/xcode ??
    Hi ...

    Is there a worthy GCC alternative to the "getche" command in win/dos c++, I've been searching the web for 3 hours now, and can't really find any solution :/.

    The thing is, that I wan't my program to wait for a keystroke (like cin, but without pressing "return")... is there some easy way to do that ??.

    Newbie thanX.

    Torben.

  2. #2
    shadov
    Guest
    SDL can do that. But if there is easier solution I'd like to hear about it too.

  3. #3
    xr600
    Guest
    Quote Originally Posted by shadov
    SDL can do that. But if there is easier solution I'd like to hear about it too.
    Yeah !... In a windows/DOS enviroment you would probably use Conio.h, but that's a no go in xcode/GCC. Someone (on another site) mentioned something about ncurses, but I'll be damned if I know how to use it .

    It really should'nt be that hard... should it ??, and please remember that I'm a complete newbie to C++ (last time I did programming Z80 Assembler code was the hottest ).

    Regards.

    Torben.

  4. #4
    binkley
    Guest
    Quote Originally Posted by xr600
    Yeah !... In a windows/DOS enviroment you would probably use Conio.h, but that's a no go in xcode/GCC. Someone (on another site) mentioned something about ncurses, but I'll be damned if I know how to use it .
    I threw together this test program quickly using curses. The only annoying aspect is that it clears the screen when "initscr()" is called.

    Code:
    #include <curses.h>
    int main() {
      int c;
    
      initscr();
    
      c = getch();
      printf("\r\nGot character: %c.\r\n", c);
    
      return 0;
    }
    Compile with "gcc getch.c -lcurses". Hope that helps.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Xcode & gcc
    By namu in forum OS X - Operating System
    Replies: 2
    Last Post: 07-13-2012, 01:15 AM
  2. GCC and xcode.
    By macosuser in forum OS X - Apps and Games
    Replies: 2
    Last Post: 06-28-2010, 01:51 AM
  3. Installing gcc on Mac OSX without re-installing XCode
    By jigglypuff in forum OS X - Development and Darwin
    Replies: 0
    Last Post: 02-26-2010, 01:16 AM
  4. C Program Trouble Compiling w/GCC, Trouble Running in Xcode
    By ebeccarayray in forum OS X - Apps and Games
    Replies: 1
    Last Post: 09-28-2009, 10:41 PM
  5. XCode - C - GCC options
    By federicog in forum OS X - Development and Darwin
    Replies: 1
    Last Post: 08-21-2007, 03:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •