...
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); time_t 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(); } } |
...