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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

kbhit & delay

Status
Not open for further replies.

mlara

Programmer
Oct 22, 2001
32
0
0
CO
Hello. I have a problem with a little c program. I have the Borland C++ 5.5.1 compiler for Win32, and I don't know how do a 'delay'. Also I don't know what function could be equal or similar to kbhit().

Thanks, for your help.
 

I am not aware of the function kbhit but for delay you can use a do loop.
 
Why can't you use kbhit? My help files indicate that it should work in Win32. For example,
Code:
while (!kbhit()) /* do nothing */ ;
should wait until someone hits a key. James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
Ok, that is ok, but I would want know a function that was compatible with Linux.

Thanks you.
 
try getch instead... but anyhow, you must include conio.h or unistd.h

then the kbhit or getch should work just type this in any function:

getch(); or kbhit();
 
Ok, and where is the sleep function declared? And this function make use of CPU clock?
 
For the sleep function u need to #include <unistd.h>
I'm not sure if it uses the CPU clock or not, but I don't think so... why? cause I've looked into a clock program and there they don't use sleep(1) to wait a second.

Hope this helps... Don't eat yellow snow...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top