RE: beepclock code attempt 2

  • From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sun, 8 Jun 2008 11:39:31 -0700

Select is a c or c++ function that waits for input on sockets or pipes.
Since standard in and out are just input pipes you can put them in the
select statement to be waited on.  It can be made to be non blocking so that
the rest of your program can continue while it is waiting on input.   When
it gets input the next time through the loop the input list will be set so
that you can test for input.   An example of this would be on this page

http://cc.byexamples.com/20070408/non-blocking-user-input-in-loop-without-nc
urses/

This is what they call a poling loop.  You loop round and round asking if
you have input if you don't you go on doing what ever you want the program
to do in your case you would want to check for input, check to see if time
had changed, and then wait one second..

Ken

Other related posts: