Hey everyone, just getting back into the groove again. I built this function and was wondering if there was anything wrong with it that might manifest later. It works fine that I can see, but it is eventually for use in game programming and such.
Edit: Actually, this would probably be unusable for what I had in mind. Would need something that times in milliseconds. Still, how does the code look?
Code:
void sleep(int seconds) {
int time = 0;
clock_t pre_time, post_time;
pre_time = clock();
while (time < seconds) {
post_time = clock();
if ((post_time/CLOCKS_PER_SEC) >= ((pre_time/CLOCKS_PER_SEC)+1)) {
time++;
pre_time = post_time;
}
}
return;
}