Thread: Returning Actual Seconds

  1. #1
    Unregistered
    Guest

    Returning Actual Seconds

    I'm trying to code a small program that acts as a 'quasi' timer.

    In the middle of the screen I need the Time HH:MM:SS
    to be refreshed every second. Starting at 00:00:00.

    Any ideas on where to begin ?
    Or does anyone have some sample code
    they wouldn't mind sharing.

    ..This Program is out of Curiosity..

  2. #2
    Unregistered
    Guest
    Code:
    #include <iostream>
    using std::cout;
    
    #include <unistd.h>
    
    int main ()
    {
        int sec = 0;
       
        while (1) {
            cout << sec++ << '\r';
            sleep (1);
        }
      
         return 0;
    }
    that's one easy way to count seconds. i'm sure there's a way to sleep with windows. i just can't remeber the header file. that should get your started, right?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to build a timer that counts the seconds elapsed?
    By Nazgulled in forum C Programming
    Replies: 17
    Last Post: 05-28-2007, 12:26 PM
  2. Problem with simple case statements
    By shoobsie in forum C Programming
    Replies: 2
    Last Post: 05-08-2006, 08:39 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. Time to seconds program
    By Sure in forum C Programming
    Replies: 1
    Last Post: 06-13-2005, 08:08 PM
  5. returning a value with char
    By kashifk in forum C++ Programming
    Replies: 5
    Last Post: 07-14-2003, 07:28 AM