//====================================================== file = sleep.c ===== //= Program to "sleep" for N seconds = //=========================================================================== //= Notes: = //= 1) Command line input is number of seconds (real number) to delay = //= with resolution to milliseconds. = //=-------------------------------------------------------------------------= //= Build: bcc32 sleep.c or gcc sleep.c = //=-------------------------------------------------------------------------= //= Execute: sleep number_of_seconds = //=-------------------------------------------------------------------------= //= Author: Ken Christensen = //= University of South Florida = //= WWW: http://www.csee.usf.edu/~christen = //= Email: christen@csee.usf.edu = //=-------------------------------------------------------------------------= //= History: KJC (04/26/99) - Genesis = //= KJC (12/27/06) - Added BSF support = //=========================================================================== #define WIN // WIN for Winsock and BSD for BSD Unix //----- Include files ------------------------------------------------------- #include // Needed for printf() #include // Needed for atoi() #ifdef WIN #include // Needed for Windows Sleep() #endif //=========================================================================== //= Main program = //=========================================================================== int main(int argc, char *argv[]) { int sleep_time; // Number of seconds to sleep // Check for sufficient command line arguments if (argc != 2) { printf("*** ERROR - incorrect number of command line arguments \n"); printf(" usage is 'sleep number_of_seconds' \n"); exit(1); } // Get sleep_time from command line arguments sleep_time = atoi(argv[1]); // Sleep for sleep_time seconds #ifdef WIN Sleep(sleep_time * 1000); #endif #ifdef BSD sleep(sleep_time); #endif return(0); }