Advertisement

time ?

Started by November 25, 2002 11:02 AM
1 comment, last by kappa the imp 21 years, 11 months ago
how do can I make so that the program waits a couple of milliseckonds then continue what it was doing?
I think this will work(ran under MS VC++)

    #include <iostream>using namespace std;#include <ctime>int main(void){	clock_t start_time, time_to_wait;		cout << "Enter the number of milliseconds you wish to wait: ";	cin >> time_to_wait;	start_time = clock();	// this is important part of the waiting	while((clock() - start_time) <= time_to_wait) {		}		cout << "All done!\n";		return 0;}    


[edited by - nobodynews on November 25, 2002 12:27:14 PM]

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!

Advertisement
use a Sleep(). if you want it to pause for 3 seconds then you set it to this: Sleep(3000). you MUST include the header ctime, it looks like this: #include <ctime>

This topic is closed to new replies.

Advertisement