Skip to main content
gamedev.net
🔒 Locked

Sleep() function?

Started by APC 6 replies 850+ views
Original Post
APC
APC
I'm trying to use the Sleep() function in c++, but can't seem to find the correct header file. Anybody know what its called? Thanks ahead of time
dave
dave
Hey bud,

The header for this is windows.h.

Hope that helps,

Dave

APC
APC
thanks. I kinda feel stupid now. :)
Fruny
Fruny
sleep() is in <unistd.h>, but might also be found in <cstdlib>, possibly renamed _sleep() on Win32 platforms.

Sleep() is likely to be in <windows.h>
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
dave
dave
Has extra functionality been added to cstdlib over stdlib.h. I looked in K & R and there was no mention of the sleep function being in stdlib.h.

Dave
APC
APC
i tried stdlib and unistd with the captial Sleep() but didn't try either with the lowercase sleep()
Fruny
Fruny
Quote:
Original post by Dave
I looked in K & R and there was no mention of the sleep function being in stdlib.h.


AFAIK, sleep() is POSIX, though not ISO. Its proper resting place is unistd.h, but Windows platform, although they claim some level of POSIX compliance, do not have that header.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.