New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

newbie Q - how to wait for keystroke in gcc/xcode ??


Post Reply New Thread Subscribe

 
Thread Tools
xr600
Guest
 
Posts: n/a

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.
QUOTE Thanks
shadov
Guest
 
Posts: n/a

SDL can do that. But if there is easier solution I'd like to hear about it too.
QUOTE Thanks
xr600
Guest
 
Posts: n/a

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.
QUOTE Thanks
binkley
Guest
 
Posts: n/a

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.
QUOTE Thanks

Post Reply New Thread Subscribe


« How exactly do I use X11? | Finding an Apple sample app (TCPLogger) »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
newbie browser question peterbt Switcher Hangout 3 01-06-2004 01:34 AM
Newbie Questions Jon Switcher Hangout 3 07-14-2003 09:38 PM

All times are GMT -4. The time now is 10:17 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?