while loop for 1 day

Oct 1, 2011 at 6:49am
how to create a while loop for 24 hours?
Oct 1, 2011 at 6:57am
You mean a loop that loops 24 times?
Think about what kind of condition would make the loop end.
Last edited on Oct 1, 2011 at 6:58am
Oct 1, 2011 at 6:58am
no a loop that loops 24 hours
Oct 1, 2011 at 7:03am
I guess
1
2
3
4
#include <ctime>
...
time_t start = time(0);
while ( difftime( time(0), start ) < 60*60*24 ) { ... }

Why would you want to do this though?
Last edited on Oct 1, 2011 at 7:04am
Oct 1, 2011 at 7:06am
oh thank you but isnt the time(0) return hours? if yes the it should be like while ( difftime( start, time(0) ) < 24 ) { ... }

never mind it returns seconds
Last edited on Oct 1, 2011 at 7:08am
Topic archived. No new replies allowed.