/* seconds.c */ /* Program that pauses. */ #include #include #include void sleep( int nbr_seconds ); void main( void ) { int x; int wait = 13; /* Pause for a number of seconds. Print a * * dot each second waited. */ printf("Delay for %d seconds\n", wait ); printf(">"); for (x=1; x <= wait; x++) { printf("."); /* print a dot */ fflush(stdout); /* force the dot to print on buffered machines */ sleep( (int) 1 ); /* pause 1 second */ } printf( "Done!\n"); } /* Pauses for a specified number of seconds */ void sleep( int nbr_seconds ) { clock_t goal; goal = ( nbr_seconds * CLOCKS_PER_SEC ) + clock(); while( goal > clock() ) { ; /* loop */ } }