// // Programmer: Craig Stuart Sapp // Creation Date: Sat Sep 19 13:57:48 PDT 1998 // Last Modified: Sat Sep 19 13:57:52 PDT 1998 // Filename: .../sig/doc/classes/Timer/examples/ex-2-Timer.cc // Syntax: C++ // $Smake: g++ -O -o %b -lsig %f && strip %b // // Description: This program will count to 10, with one number // displayed per second. The timer is counting // in units of 96 ticks per second. The flush command // in the print statement prevents buffering of the counted // number by forcing it to print immediately. #include "Timer.h" #include int main(void) { Timer stopwatch; int counter = 0; stopwatch.reset(); stopwatch.setTicksPerSecond(96); // 96 time units per second while (counter <= 10) { if (stopwatch.getTime() > counter * 1000) { cout << counter << " " << flush; counter++; } } cout << endl; return 0; }