|
From: Chad S. <ho...@ho...> - 2000-11-29 21:39:41
|
>From: "Chris Bunney" <ch...@cb...>
>Reply-To: dev...@li...
>To: <dev...@li...>
>Subject: Re: [Dev-C++] Delay
>Date: Wed, 29 Nov 2000 18:35:47 -0000
>
>Ian,
>
>Hi. I dont think dev-c++ has a delay command so I wrote my own, here is the
>code:
>
>#include <ctime>
>
>void delay(int seconds)
>{
> clock_t current, end;
>
> current = clock();
> end = current + CLOCKS_PER_SEC * seconds;
>
> while(current < end)
> current = clock(); // loop while current not equal end
>}
Eww.. Waste of CPU time. I suggest using the Win32 API Sleep or _sleep
functions instead. The reason is that your above delay function is
constantly working the CPU as it goes through the loop. The Sleep or_sleep
functions on the otherhand will actually halt the program until the set
amount of time has passed.
Chad Simmons
_____________________________________________________________________________________
Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com
|