'What is the most accurate way to cap frame rate in C++?

I need the frame rate of my code loop to be exactly 20 milliseconds to the micro second. The way I was doing this before works somewhat, but it’s not working in a different class function. I don’t have my code to paste now sadly. However, I would like to know what the most accurate to the microsecond way to make the time be 20 milliseconds every time.

c++


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source