一个简单的计时器
1 #include <iostream> 2 using namespace std; 3 4 void show() 5 { 6 static int i = 0; 7 long t = time(NULL); 8 while(t == time(NULL)); 9 cout << "当前是第 " << i++ <<" 秒;" << endl; 10 } 11 12 int main(int argc, char *argv[]) 13 { 14 for(;;) 15 show(); 16 return 0; 17 }