/* From Info-Unix mailing list.... May 1990 >I want to do some computation and be able to stop by a key pressed by the >user. Turbo C has a function kbhit() and Turbo Pascal has keypressed(), >but what can be done with UNIX? I've looked into the stdin structure: Try this.: -- Jim Patterson Cognos Incorporated */ int kbhit() /* returns the number of characters waiting, since last read */ { long count; /* Add up the count of characters in the file buffer */ /* and the count of characters in the device buffer. */ count = 0; if( stdin != NULL ){ ioctl( stdin->_file, FIONREAD, &count ); count += stdin->_cnt; } return( (int)( count ) ); } /* kbhit */ /* dick@csci.csusb.edu=rbotting@wiley.csusb.edu. Disclaimer::=`I and CSUSB are not responsible for this code. Use intelligently a nd at your own risk`. */