Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!elroy.jpl.nasa.gov!zardoz.cpd.com!dhw68k!arcturus!evil From: evil@arcturus.UUCP (Wade Guthrie) Newsgroups: comp.lang.c Subject: Re: getting a key from stdin in UNIX Message-ID: <7184@arcturus> Date: 7 Feb 90 16:40:15 GMT References: <2802@cunixc.cc.columbia.edu> <22287@mimsy.umd.edu> Organization: Rockwell International, Anaheim, CA Lines: 44 Gary Mathews writes: > I want to be able to press a key and respond to that key without >pressing the key, such as getc on TurboC... Chris Torek writes: [...] >It should therefore not appear in this newsgroup. Sorry to disagree with you on this one, Chris, but what about those of us that can answer the question in a non-machine specific way? Try using curses, a public domain package that exists on many systems including Unix, VMS (albeit in a bass-ackwards sort of way), and MS-DOS. By putting the terminal into 'raw' mode, you can do what is being asked. In fact, I end up using curses a lot to handle portable menus and such. Your code should look something like: #include main(argc, argv) ... initscr(); /* starts curses */ ... raw(); /* puts the input mode to raw */ c = getch(); /* in raw mode, this just gets the char -- no * newline required */ noraw(); /* returns to cooked mode */ ... endwin(); } Or some such. Check out the curses manual for details. Wade Guthrie evil@arcturus.UUCP Rockwell International; Anaheim, CA (Rockwell doesn't necessarily believe / stand by what I'm saying; how could they when *I* don't even know what I'm talking about???)