Solution for Exercise 21-4
ex2104
#include <stdio.h> #include <time.h> int main() { time_t tictoc; int x; for(x=0;x<20;x++) { time(&tictoc); printf("%2d:%ld\n",x+1,tictoc); } return(0); }
Notes
* Setting the for loop value to 200000 on my Intel Core i7 system allowed me to see the time_t
value roll over. That doesn't mean that 200,000 spins of a loop takes the system approximately one second to accomplish. Most of the delay is due to writing text to the terminal window and scrolling the screen.
Copyright © 1997-2024 by QPBC.
All rights reserved