and so on
[C] delay함수
밀크빵
2011. 9. 16. 01:23
#include <windows.h> // sleep사용
void delay(clock_t sleep)
{
clock_t cur = clock(), el;
for(;;){ /* 무한루프를 돌린다. */
el = clock(); /* 현재까지 프로그램이 실행된 TICK */
if((el - cur) > sleep)
break ;
}
}
void delay(clock_t sleep)
{
clock_t cur = clock(), el;
for(;;){ /* 무한루프를 돌린다. */
el = clock(); /* 현재까지 프로그램이 실행된 TICK */
if((el - cur) > sleep)
break ;
}
}
void Delay(int milli_second)
{
clock_t current_time, end_time;
current_time = clock() * (1000/ CLOCKS_PER_SEC);
if(current_time == (clock_t)-1)
exit(EXIT_FAILURE);
end_time = current_time + milli_second;
while(current_time < end_time)
{
current_time = clock() * (1000/CLOCKS_PER_SEC);
}
}