wouldn't you be better off starting your first timer then whatever time between its stopping and starting the other timer devise a method to all it as soon as your start timer has quit. something like this?
Code:
#include <iostream>
#include <ctime>
#include <cstdlib>
void start_one(int a);
void start_two(int a);
int main()
{
start_one(2);
// start it here or call in as soon as the first one stops
//start_two(5);
return 0;
}
// seconds laps time in prams
void start_one(int a)
{
clock_t startTime = clock(); //Start timer
double secondsPassed;
double secondsToDelay = a;
bool flag = true;
//call here to fire imminently then stay until
// times up
while(flag)
{
secondsPassed = (clock() - startTime) / CLOCKS_PER_SEC;
if(secondsPassed >= secondsToDelay)
{
// put in here what you want ran to
// to start after delay
std::cout<< " timer one"<<std::endl;
flag = false;
secondsPassed = 0;
startTime = clock();
}
}
start_two(5); // here as soon as this one is over with it will start the other one
}
void start_two(int a)
{
clock_t startTime = clock(); //Start timer
double secondsPassed;
double secondsToDelay = a;
bool flag = true;
while(flag)
{
secondsPassed = (clock() - startTime) / CLOCKS_PER_SEC;
if(secondsPassed >= secondsToDelay)
{
// put in here what you want ran
std::cout<< " timer two"<<std::endl;
// no resetting flag it will run forever
// fires every x sec elapse time
secondsPassed = 0;
startTime = clock();
}
}
}
or just call both to start at the same time, but I am guessing this is causing conflict if it is
controlling the same thing at the same time.