Hi there!
I looking for a simple function to do a delay in my programs,
I could'nt find one on the libraries listed on the net.
I've tried do one witch for loops, but my computer is fast, and there's no effect.
So, if someone could help.
thanks!
Hi there!
I looking for a simple function to do a delay in my programs,
I could'nt find one on the libraries listed on the net.
I've tried do one witch for loops, but my computer is fast, and there's no effect.
So, if someone could help.
thanks!
Sleep( ) is a good one, also there is delay( ) which is defined in dos.h.
Good luck.
just to mention, the Sleep() function requires windows.h
Ilia Yordanov,
http://www.cpp-home.com ; C++ Resources
#include <iostream>
#include <ctime>
using namespace std;
void sleep()
{
double seconds = 1.5;
clock_t timer;
timer = clock() + seconds * 1000;
while (clock() < timer) {}
}
int main()
{
cout << "I am now!!!" << endl;
sleep();
cout << "I am 1.5 seconds later" << endl;
return 0;
}
I think this should work, if I remember I got it correct
Good luck!!
What liberaries posted on the net, i sure would like to see that.
WorkStation(new, a month ago):
Sony Vaio i686 Desktop
2.60 GIGhz Intel Pentium 4(HT)
512Mb DDR RAM
800MHz Front Side Bus!
120 GIG IDE HardDrive
Matrox G400 Dual-Head
Linux kernel 2.6.3
Modified Slackware 9.1
GCC/GDB
Multi-mon
Simultaneous Multiple Processes