+ 3
If you don't need to execute any other code will doing the delay, then the cross platform way to do it with C++11 and above is to use "std::this_thread::sleep_for()" from the thread header. Heres an example:
#include <thread>
#include <chrono>
#include <iostream>
int main()
{
std::this_thread::sleep_for(std::chrono::seconds(3));
std::cout << "Hello world!\n";
std::cin.get();
}
/////////////////////////////////////////////////////////////////////////////////////////
Another way is to execute code while keeping track of a timer:
int main()
{
auto tbegin = std::chrono::system_clock::now();
while (std::chrono::system_clock::now() - tbegin < std::chrono::milliseconds(400))
{
std::cout << "Hello world!\n";
}
std::cin.get();
}