Solution for Exercise 21-11
ex2111
#include <stdio.h> #include <time.h> int main() { time_t now,then; float delay=0.0; time(&then); puts("Start"); while(delay < 1) { time(&now); delay = difftime(now,then); printf("%f\r",delay); } puts("\nStop"); return(0); }
Notes
* Sample output:
* Lamentably, on my system at least, the value is in whole seconds not fractional parts. So the net effect of the while loop is to pause program execution for one second. Therefore:
* Modify the code so that the value 1 in Line 11 is changed to a higher value.
* You can also use the difftime() function to perform time math. The thought of doing so frightens me utterly.
Copyright © 1997-2024 by QPBC.
All rights reserved