How do I sleep in my MSVC++ console application?
Solution 1
Sleep is defined in Winbase.h, but you should include Windows.h to get it.
In the future you can find your information for yourself by bringing up the Help from VisualStudio or searching MSDN. All such info on Win32 API calls should be in there.
Solution 2
Sleep Using WINAPI Sleep(__in DWORD dwAtleastFor8HoursForGoodHealth);
Include Winbase.h or Windows.h
Solution 3
you just Sleep(asManyMilliSecondsAsYouWant);
Solution 4
Sleep(int milliseconds) is a Win32 API to suspend execution of your program for the set number of milliseconds.
Include <windows.h>
to get access to it.
MSDN usually lists what header files and libraries API's are in.
Solution 5
This might be a bit too late (for the 'asker' :)), but in MSVC (2010) (console application) the sleep is in SECONDS not Milliseconds.
Skylark
Updated on June 05, 2022Comments
-
Skylark almost 2 years
I want to call Sleep(x), where x is milliseconds to sleep. I know this is the function, but it doesn't work for me. What do I need to include?
---SOLVED---
I was using the compiler option /Za, which disabled the native Windows extensions used in Sleep()'s implementation.