How would you make the program pause for a certain amount of time? I can't just tell it to do some trivial task over and over for so many loops, because the compiler seems to know its trivial and cuts it out. There's gotta be a simpler way anyway.
LieAfterLie 10 Light Poster
Recommended Answers
Jump to Post— Grunt 19OS and Compiler?
Jump to Post— andor 25How would you make the program pause for a certain amount of time? I can't just tell it to do some trivial task over and over for so many loops, because the compiler seems to know its trivial and cuts it out. There's gotta be a simpler way anyway.
Try …
Jump to Post— vegaseat 1,735If you are using Windows and Dev-C++ then the function is Sleep(milliseconds) ...
#include <cstdlib> #include <iostream> #include <windows.h> // needed for Sleep(millisec) using namespace std; int main(int argc, char *argv[]) { cout << "start..." << endl; Sleep(2000); cout << "done..." << endl; system("PAUSE"); return EXIT_SUCCESS; }
Jump to Post— ~s.o.s~ 2,560Better not call the "system" functions like
system ("pause").Your job can be very well done using the function
cin.get()which does the same function without invoking the system procedures which incur heavy overheads.
All 16 Replies
Grunt 19 Junior Poster
andor 25 Posting Whiz in Training
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
Member #46692
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
LieAfterLie 10 Light Poster
aeinstein commented: Always nice to see someone post how there issue was resolved. +10
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.