Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Borland C++ 4.5compiler not recognizing sleep function,have dos.h

Status
Not open for further replies.

mattholomew

Programmer
Oct 10, 2000
4
0
0
US
The Sleep(function), defined in dos.h, is not being recognized by my compiler(Borland C++ 4.5, and I have NO IDEA WHY. Everytime I run it, it says, 'compiler error: 'sleep()' function not defined in prog5_2.' (I am doing the Windows Game Programming for Dummies, in case anyone cares.) In this book, the author has forgotten header files before, and he forgot dos.h, so I put it in when it didn't work without it, and it still doesn't work. I might try going into dos.h and hacking out the definition myself. (When the going gets tough, the tough try a hacksaw and blowtorch.) However, I have already tried this and failed the first time, and additionally, those things are so cryptic it gave me a major headache. This is the non-functioning section of code in my program...

Sleep(10) ;

The way to use the sleep function, so happily provided by the help contents, is: void sleep (unsigned seconds) ;

I decided to try this before the hotline. If anyone could help, I would appreciate it.
 
Perhaps this is a problem of operating system. Sleep does not work with 16-bit Systems like Windows 3.11
 
mattholomew,

Isn't Sleep(10) sleep for 10 MILLIseconds

In which case it is probably working

Try
Sleep(1000); // wait 1 second
You will definitely see the effect of this

Roy Thomas

 
Either in VC++ in the Dos.h there is not a sleep or delay function.

Also the difference between sleep and delay is that
sleep has as argument number of seconds and the delay has
number of milliseconds

Marios Koumides
marios.koumides@wmich.edu
 
The old sleep() function is named _sleep() in dos.h file so use that one =)
 
If dos.h is not recognized by the compiler then goto:
File-> New-> Project...->
choose "DOS STANDARD" from PLATFORM DROPDOWN BOX (you may have to type in the path of where you want to save your file manually).
Click "OK"
A window will pop up...
Click on "whatever_name.cpp" and hopefully...TAADAA!!!!!!!

 
I checked it on my Systems (Windows 3.11 and Windows NT)

the Result

Windows 3.11: Sleep is not found

Windows NT: it works.

The explanations can be found in the manual.




hnd
hasso55@yahoo.com

 
Are there any other common headers, or ones in Borland C++ 4.5, that has something similar as the delay function?
 
One method could be, use a timer and programm a Timer Event function with the Functionality you need.

hnd
hasso55@yahoo.com

 
I'm fairly new to C++ and Borland's compiler, and I had the same problem. I did recently read in the on-line help (Borland Turbo C++ 4.5) that dos.h functions cannot be used in EasyWin. If you are using EasyWin, you'll (and me) have to find an alternative.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top