Just to add on to the post the syntax for sleep (WinAPI) is:
=20
-------------------------------------------------------------------------=
-------
sleep(DWORD milliseconds);
-------------------------------------------------------------------------=
-------
----- Original Message -----=20
From: Chad Simmons=20
To: dev...@li...=20
Sent: Wednesday, November 29, 2000 1:39 PM
Subject: Re: [Dev-C++] Delay
>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=20
>code:
>
>#include <ctime>
>
>void delay(int seconds)
>{
> clock_t current, end;
>
> current =3D clock();
> end =3D current + CLOCKS_PER_SEC * seconds;
>
> while(current < end)
> current =3D 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=20
constantly working the CPU as it goes through the loop. The Sleep =
or_sleep=20
functions on the otherhand will actually halt the program until the =
set=20
amount of time has passed.
Chad Simmons
=
_________________________________________________________________________=
____________
Get more from the Web. FREE MSN Explorer download : =
http://explorer.msn.com
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users
-------------------------------------------------------------------------=
-----
|