home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19296 < prev    next >
Encoding:
Text File  |  1993-01-06  |  1.2 KB  |  36 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!munnari.oz.au!newsroom.utas.edu.au!sol!quan
  3. From: quan@sol.surv.utas.edu.au (Stephen Quan)
  4. Subject: Re: Unix equivalent to DOS kbhit() function?
  5. Message-ID: <quan.726301609@sol>
  6. Sender: news@newsroom.utas.edu.au
  7. Organization: University of Tasmania, Australia.
  8. References: <1992Dec29.073337.2693@kum.kaist.ac.kr>
  9. Date: Wed, 6 Jan 1993 06:26:49 GMT
  10. Lines: 24
  11.  
  12. typhoon@stcon2.kaist.ac.kr (Han Yun-Su) writes:
  13. >I wrote 'kbhit()' function for UNIX.
  14. >It's very simple..
  15.  
  16. [...rest of C program omitted...]
  17.  
  18. >  while (c != 'q') {
  19. >    count++;
  20. >    if (kbhit()) {
  21. >      c = getch();
  22. >      mvprintw(1, 0, "%d: \'%c\' is pressed (count: %ld)\n", ++i, c, count);
  23. >      refresh();
  24. >      }
  25. >    }
  26.  
  27. If your UNIX platform is like ours, I recommend you put a some kind of
  28. delay in your while loop, [or perhaps in the kbhit() function] otherwise
  29. your process may use large amounts of CPU time.  Otherwise not a bad
  30. program for a Life Science Major!
  31. --
  32. Stephen Quan (quan@sol.surv.utas.edu.au)      Tel : 002 202844 (local)
  33. Research Fellow, Computer Scientist,          Fax : 002 240282 (local)
  34. Centre for Spatial Information Systems,       Tel : 61 02 202844
  35. University of Tasmania, Australia.            Fax : 61 02 240282
  36.