Advertisement
CH1156

A timer I made in C++

Oct 22nd, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <time.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int minutes = 0;
  10.     int hours = 0;
  11.     int seconds = 0;
  12.     int days = 0;
  13.  
  14.     while(true)
  15.     {
  16.         system("cls");
  17.         time_t current = time(0);
  18.         cout << ctime(&current) << endl;
  19.         cout << "Days: " << days << endl;
  20.         cout << "Hours: " << hours << endl;
  21.         cout << "Minutes: " << minutes << endl;
  22.         cout << "Seconds: " << seconds << endl;
  23.  
  24.         for(int i = 0; i < 1; i++)
  25.         {
  26.             seconds += 1;
  27.         }
  28.  
  29.             if(seconds == 60)
  30.             {
  31.                 minutes += 1;
  32.                 seconds = 0;
  33.             }
  34.             if(minutes == 60)
  35.             {
  36.                 hours += 1;
  37.                 minutes = 0;
  38.             }
  39.             if(hours == 24)
  40.             {
  41.                 days += 1;
  42.                 hours = 0;
  43.             }
  44.             Sleep(1000);
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement