clock

This is a discussion on clock within the C++ Programming forums, part of the General Programming Boards category; How do you make a clock that runs in dos(The clocks time the same as the computers time)?...

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

    clock

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

  2. #2
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    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, 01: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, 06:15 AM
  4. clock program
    By bazzano in forum C Programming
    Replies: 3
    Last Post: 03-30-2007, 11:12 PM
  5. System clock
    By bazzano in forum C Programming
    Replies: 10
    Last Post: 03-27-2007, 11:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21