Thread: Timing programs

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Event driven programming can be done quite easily without tracking the time. You may want to revise your input/output design though. You can still use the command-line arguments, but once main exits, the user will need to run the program again.

    So you need to ask the user explicitly if he wants to quit, and then return from main. Depending on your design it can be as simple as this while loop:
    Code:
    int mode;
    while( (mode = getchar()) != 'x') {
        puts("Checking server.");
        checkserver();
        fputs("Quit? ", stdout);
    }
    Last edited by whiteflags; 07-08-2006 at 04:01 PM.

  2. #2
    Registered User
    Join Date
    Jul 2002
    Posts
    17
    Well the time is there so every 5 minutes it checks the server status, and if its down, boots it. So thats why i've got the time there. Unless there is a way you can continueosly run the check so as soon as it goes down, it'll now and boot the program.

    I just basically want the thing to keep running until the user tells it to stop running, or he exits the program.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. timing the C
    By stabu in forum C Programming
    Replies: 6
    Last Post: 09-12-2008, 06:29 AM
  2. Recommend upgrade path for C programs
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-22-2007, 07:32 AM
  3. POSIX/DOS programs?
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 02-28-2003, 05:42 AM
  4. executing c++ programs on the web
    By gulti01 in forum C++ Programming
    Replies: 4
    Last Post: 08-12-2002, 03:12 AM
  5. Timing in Windows
    By steinberg in forum Windows Programming
    Replies: 3
    Last Post: 07-14-2002, 12:43 AM