Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Iterate on second

Name: Anonymous 2007-08-25 6:47 ID:sc0LfXCq

I've been trying to make a loop that will only repeat when a second has passed.  Basically it will check every second to see if the current time is equal to a specified time.  At the moment my program just repeats the same number about a thousand times before  it reaches the next one...any halp guyz?

Name: Anonymous 2007-08-25 6:52 ID:Heaven

#include <time.h>
main() {
    for (;;) {
        int n = time(NULL);
        while (n == time(NULL));
        /* do stuff */
    }
}

Name: Anonymous 2007-08-25 7:11 ID:sc0LfXCq

Thanks

Name: Anonymous 2007-08-25 7:32 ID:cICFCcXL

BETTER USE 64BIT INTS FOR TIME OR YOUR COMPUTER MIGHT EXPLODE IN THE YEAR 3000

Name: Anonymous 2007-08-25 8:57 ID:H+UGOQMq

>>4
time_t n = time(NULL);
PROBLEM SOLVED.

>>2
int main(int argc, char **argv){
 for(;;sleep(1)){
  /* do stuff */
 }
}

Name: Anonymous 2007-08-25 9:31 ID:oBiyS5rs

>>2
Ouch, enjoy your 100% CPU utilization

Name: Anonymous 2007-08-25 10:39 ID:h2yqsUSa

>>5
>>6
Assholes! YOU  dont yudnerstand /prog/

Name: Anonymous 2007-08-25 11:14 ID:ixTwDEXe

>>6
show me something better (its not a sarcasm, just a plain request)

Name: Anonymous 2010-11-13 15:10


Don't change these.
Name: Email:
Entire Thread Thread List