Thread: clock

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    43

    clock

    How do you make a clock that runs in dos(The clocks time the same as the computers time)?

  2. #2
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    Very lame Windows-specific method:

    Code:
    #include <iostream>
    #include <cstdlib>
    #include <ctime>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
      while (true)
      {
        time_t curr = time(0) ;
        cout << "Time: " << ctime(&curr) << endl ;
        Sleep(1000) ;
        system("cls") ;
      }
      
      system("PAUSE");	
      return 0;
    }

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    There is some information in the Programming FAQ that should be helpful.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Logical Error in Clock program
    By SVXX in forum C++ Programming
    Replies: 0
    Last Post: 05-10-2009, 12:12 AM
  2. Outside influences on clock cycles? (clock_t)
    By rsgysel in forum C Programming
    Replies: 4
    Last Post: 01-08-2009, 06:15 PM
  3. Clock Troubles
    By _Nate_ in forum C Programming
    Replies: 22
    Last Post: 06-19-2008, 05:15 AM
  4. clock program
    By bazzano in forum C Programming
    Replies: 3
    Last Post: 03-30-2007, 10:12 PM
  5. System clock
    By bazzano in forum C Programming
    Replies: 10
    Last Post: 03-27-2007, 10:37 AM