0

I have a chrono timer setup to count up until 'x' amount of time. So inside this while loop, how can I make the program trigger a function at specific intervals (e.g. every 1 min, every 2 sec, etc.)

const double LIMIT = 5.0 ;

int main(){

    cout << "-- Email Simulation --" << endl;

    Timer timer;   
    timer.start();



    while( timer.elapsedSeconds() < LIMIT ){
         // do stuff here
    }


    timer.stop();
    cout << "Elapsed Time : " << timer.elapsedSeconds() << "s" << endl;

    return 0;
}

I tried to use this method but that triggers the function more than once which is not what I want.

if( timer.elapsedSeconds() == x ){
     // do stuff
}
poh
  • 1
  • 1
  • 4

0 Answers0