C Timers

Discussion in 'Programming/Scripts' started by dualxeon, Feb 23, 2008.

  1. dualxeon

    dualxeon New Member

    I have written the following script in C to show the word bang every three seconds. However its not working correctly, heres the script:

    #include <stdio.h>
    #include <time.h>
    int main ()
    time_t rawtime;
    int start_time;
    int now;
    start_time = time(&rawtime);
    now = time(&rawtime);
    if (now - start_time >3) {
    printf ("BANG!!");
    //start_time = now;
    goto loop;
    return 0;
    At the moment, when I run this script after 3 seconds it constantly outputs bang though I only want this once per 3 seconds. To me it make sense if you uncomment the line
    //start_time = now;
    this should make output once every 3 seconds, but instead it doesnt at all,
    Any help would be apreicated,
  2. dualxeon

    dualxeon New Member

    problem solved
  3. falko

    falko Super Moderator ISPConfig Developer

    Do you mind to tell us how? ;)
  4. dualxeon

    dualxeon New Member

    sure,i used the C sleep function instead

Share This Page