Thread: clock

  1. #1
    Registered User
    Join Date
    Mar 2003


    Hi there

    Is there a way to create the clock or show the system clock
    and it can also tick as the seconds changes


  2. #2
    Registered User
    Join Date
    Apr 2002
    You can do it with a windows function.

    Look up
    VOID GetSystemTime( LPSYSTEMTIME lpSystemTime );
    If your unfamiliar with windows I can try to help you a little further. Basically the LP before the struct name is a typedef for a pointer to it. You pass the structure and it will fill it in with the appropriate information.

    Good Luck.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    #include <stdio.h>
    #include <string.h>
    #include <time.h>
    int main(void)
       time_t now, last = time(&now), end = now + 10;
       while ( now < end )
          if ( last < time(&now) )
             char *text = ctime(&now), *newline = strchr(text, '\n');
             *newline = '\0';
             printf("\r%s", text);
             last = now;
       return 0;
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

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