So I was trying to make a program that completes task in a specific amount of time but every timing example I came across uses a type of sleep to wait a certain amount of time, i know there is probably a way to have it where the task is completed, in my case a loop, for a specified amount of time, regardless of the amount of times the loop is run. (i need it to run a while loop for a specified amount of time without dictating the amount of times the loop is run and end the loop after the time is up)
You'll need to set up a timer class with a data member timeStart = 0 set by the class ctor and then a method which would return clock() - timeStart which you can pass to a while loop using a timer object.
ps: the link, and my suggestion referencing it, uses the ctime library and it's methods but you may also wish to consider the chrono library which is more accurate and the current preferred C++ option