Is there a decent way to make a program delay for a certain amount of time?

I have always wondered about how to make a program delay for a certain amount of time with just basic C++ and no external libraries if at all possible, cause i know SFML has code to assist with that. I mean you can do something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>

using std::cout;
using std::endl;

int main()
{
	cout << "Hello" << endl;

	for (int i = 0; i < 900000000; i++)
	{

	}

	cout << "world" << endl;
}


But that may run faster or slower depending on your CPU(I have an i7-9700k so this takes like 1/12-2 seconds to run), I dont really know. I dont want to use stuff like sleep or pause. What would be a good way to accomplish this?

Im not using it in a program or anything im just curious.
Last edited on
std::this_thread::sleep_for()
Topic archived. No new replies allowed.