home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / os2 / programm / 6600 < prev    next >
Encoding:
Text File  |  1992-11-21  |  1.2 KB  |  36 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!grebyn!daily!richk
  3. From: richk@grebyn.com (Richard Krehbiel)
  4. Subject: getchar() without <enter> in emx gcc?
  5. Message-ID: <1992Nov21.154701.16804@grebyn.com>
  6. Lines: 21
  7. Sender: richk@grebyn.com (Richard Krehbiel)
  8. Organization: Grebyn Timesharing
  9. Distribution: usa
  10. Date: Sat, 21 Nov 1992 15:47:01 GMT
  11.  
  12. This is a very common FAQ in comp.lang.c, so I hate to ask....
  13.  
  14. How do you read a single character from the keyboard without requiring
  15. hitting ENTER, and without echo?
  16.  
  17. Specifically, this is in emx gcc 0.8e.  I'm incuding what I'm trying
  18. now, but it doesn't work.  It does in Unix, which I thought the termio
  19. interface in emx was supposed to emulate.
  20.  
  21.         setbuf(stdin, NULL);
  22.         ioctl(0, TCGETA, &tio);
  23.         tio.c_lflag &= ~(ICANON | ECHO);
  24.         tio.c_cc[VMIN] = 1;
  25.         tio.c_cc[VTIME] = 0;
  26.         tio.c_cc[VEOL] = 0;
  27.         ioctl(0, TCSETA, &tio);
  28.  
  29. After this, characters are still automatically echoed and buffered,
  30. etc.
  31.  
  32. (And if this is a FAQ, please don't hit me too hard...)
  33. -- 
  34. Richard Krehbiel                                 richk@grebyn.com
  35. OS/2 2.0 will do for me until AmigaDOS for the 386 comes along...
  36.