how can I set short delay when program is running ?

e.g. print "processing..." and pause program there for 3 seconds.
cout << "Processing..." << endl;

This will pause the program for roughly 3 seconds.
but, which library to use ?
A five second search would tell you it's dos.h. You need to learn to find these things out quickly rather than waiting around on a forum.

Word of Advice: Don't add stuff like "Processing..." to your program for no reason. It will either come off as a silly attempt to look cute or worse, it will look like your code is buggy. Spend your time coding things that are actually useful to your end-user for now. You can make cool looking programs after you learn some GUI proramming.
In standard C++, it's std::this_thread::sleep_for(std::chrono::seconds(3));

It's a fairly new function, not every compiler may have it out of the box. In particular, GCC needs to be passed the commandline options -std=c++11 -D_GLIBCXX_USE_NANOSLEEP -pthread. If you're stuck with something that doesn't have it, get boost ( if it's not already installed on your system). If you can't get boost, look at your OS API but get boost anyway.
Last edited on
Topic archived. No new replies allowed.