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

I want to put a 3 second delay in my program

Status
Not open for further replies.

zoonkai

MIS
May 1, 2000
71
US
I'm a rookie to C++ so forgive me if this question is simplistic<br><br>if the user puts in incorrect input i want it to put the error....delay 3 seconds then give him another chance<br><br>after searching, i found a delay() command...but everytime i try to compile....it says that delay() is not defined..<br><br>i have included iostream, string, conio, and attempting to make this work&nbsp;&nbsp;'time' also......i don't know what to do...<br><br>any help would be greatly appreciated<br>Thanx<br>Donald<br><br><A HREF="mailto:zoonkai2@aol.com">zoonkai2@aol.com</A> or <A HREF="mailto:donnan@don-nan.com">donnan@don-nan.com</A><br><br> <p>Donald (Zoonkai) Dixon<br><a href=mailto:donnan@don-nan.com>donnan@don-nan.com</a><br><a href= Pump & Supply Co.</a><br>
 
Zoonkai,<br><br>I haven't heard of the delay command, but your best bet is to include the cstdlib, or<br>with some compilers, the stdlib.&nbsp;&nbsp;If that doesn't work and you don't mind the poor style, you can always put a for loop in that runs without actually doing anything and just eats up time.&nbsp;&nbsp;<br><br>&nbsp; <p>-Pitt-<br><a href=mailto:pitt6969@mindless.com>pitt6969@mindless.com</a><br><a href= Heaven</a><br>
 
There are different possibilities to program a delay:<br><br>The function delay<br><br>The function sleep<br><br>Or if you have a window system you may use a timer which sends a &quot;Wakeup&quot; signal to itself.<br><br>in the moment I do not have an actual source, but each method works.<br><br> <p>M. Hund<br><a href=mailto:Manfred.hund@planet-interkom.de>Manfred.hund@planet-interkom.de</a><br><a href= > </a><br>
 
Use Sleep function . Which takes milliseconds as a parameter. So pass sleep(3000); . <br><br>Siddharha singh <p>Siddhartha Singh<br><a href=mailto:siddhu_singh@hotmail.com>siddhu_singh@hotmail.com</a><br><a href=siddhu.freehosting.net> </a><br>
 
The delay function is defined in dos.h. If you want to find where the functions are defined use the search index for compiled header files.(extension h)
 
Hi,

You need to include dos.h to use the delay() function.

 
a o l
hi mr.

u need to added dos.h than ur required delay can be achieved.

note that sentex.

delay(1000);

will delay program for one second.

ok

bye
 
use the clock() function like this
#include <time.h>

int main()
{


//Following code stops program for 3 seconds put
//command after the while loop not in the {}
clock_t start_time;
start_time = clock();

while((clock() - start_ time) < 3 * CLOCKS_PER_SEC)
{
}

return(0);



}


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top