Real Time?

This is a discussion on Real Time? within the C Programming forums, part of the General Programming Boards category; So I have a clock problem to. I want to update the clock in real time so that I can ...

  1. #1
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,600

    Real Time?

    So I have a clock problem to. I want to update the clock in real time so that I can see the seconds tick by!
    Here's what I am using:

    char *aORp;
    int tm_year;
    struct tm *systime;
    time_t t;
    t=time(NULL);
    systime=localtime(&t);
    if(systime->tm_hour>12) {systime->tm_hour=
    systime->tm_hour-12; aORp = "p.m."; }
    else{aORp = "a.m.";}

    I would hate to call "t=time(NULL);" every other line of code!(And I'm sure it's not done this way).

    But I just don't know how to write a function that runs constantly yet releases the rest of the program to resume normally!
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

  2. #2
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    use a master loop which contains this updating code and any other code you'd want to have run simultaneously... then use static or global data [*gulp*] to save the states for continuation in the next cycle...
    hasafraggin shizigishin oppashigger...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Weird Times I'm getting
    By afflictedd2 in forum Linux Programming
    Replies: 8
    Last Post: 07-23-2008, 07:18 AM
  2. Real time access to display image
    By abachler in forum Windows Programming
    Replies: 3
    Last Post: 07-21-2008, 05:30 PM
  3. time synchronization problem
    By freeindy in forum C Programming
    Replies: 1
    Last Post: 04-19-2007, 06:25 AM
  4. Programming Puns
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 44
    Last Post: 03-23-2002, 03:38 PM
  5. time class
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-11-2001, 09:12 PM

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