...
Code Block | ||
---|---|---|
| ||
int do_work(int seconds_to_work) {
time_t start;
start = time(0);
if (start == (time_t)(-1)) {
/* Handle error */
}
while (time() < start + second_to_work) {
do_some_work();
}
}
|
...
Code Block | ||
---|---|---|
| ||
int do_work(int seconds_to_work) { time_t start; time_t current; start = time(0); current = start; if (start == (time_t)(-1)) { /* Handle error */ } while (difftime(current, start) < seconds_to_work) { current = time(0); if (current == (time_t)(-1)) { /* Handle error */ } do_some_work(); } } |
...
Wiki Markup |
---|
\[[Kettlewell 02|AA. C References#Kettlewell 02]\] Section 4.1, "time_t"
\[[ISO/IEC 9899-1999|AA. C References#ISO/IEC 9899-1999]\] Section 7.23, "Date and time <time.h>" |
...