Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » need help delaying a loop output c++
Closed Thread
Old 02-21-2006, 10:05 PM   #1 (permalink)
 
Monster Techie

Join Date: Apr 2005

Posts: 1,909

jcortes is on a distinguished road

Send a message via AIM to jcortes
Default need help delaying a loop output c++

hey i was making a program but i want it to loop some text but have a delay after each line of about 1 second. any ideas how i can accomplish this.
__________________

AIM = jcortestechhelp
jcortes is offline  
Old 02-22-2006, 02:52 PM   #2 (permalink)
 
Newb Techie

Join Date: Mar 2005

Posts: 39

psyb0rg

Default

I think theres a sleep(...) function in windows.h . It takes the required delay time as the parameter
psyb0rg is offline  
Old 02-22-2006, 05:55 PM   #3 (permalink)
 
True Techie

Join Date: Jul 2004

Posts: 235

crazybeans

Default

You can also use this:

#include <iostream>
#include <ctime>

using namespace std;

int main()
{

clock_t delay;
clock_t start;

// your loop here (eg: while, for, etc.)
delay = 0.3 * CLOCKS_PER_SEC; // replace 0.3 with your delay in seconds
start = clock();
while(clock() - start < delay)
;
// end your loop here

return 0;
}
__________________
Come visit a new technology and digital image arena website where you may compete in monthly image contests and chat about technology. t3ch.l33t is currently searching for members to help manage different areas of the site. t3ch.l33t Image Arena Home

http://img.photobucket.com/albums/v3...ch_l33tsig.jpg
crazybeans is offline  
Old 02-23-2006, 10:27 AM   #4 (permalink)
 
Monster Techie

Join Date: Apr 2005

Posts: 1,909

jcortes is on a distinguished road

Send a message via AIM to jcortes
Default

ok thanx alot that worked out great
__________________

AIM = jcortestechhelp
jcortes is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On