I want to get the time difference between certain moments of objects life but it seems that variables in them stay unchanged!
// variables
time_t start;
time_t no_infection;
bool time_already_set = 0;
bool infected_or_not = 0;
int not_infected_t = 0;
void bacteria::set_time() {
if (infected_or_not == 1 && time_already_set!=1) {
start = clock();
time_already_set = 1;
}
}
//It seems that time variables do not change during the program I test it using get functions
The divisions by CLOCKS_PER_SEC are integer divisions. You could define for example a constdouble double_clocks_per_sec = CLOCKS_PER_SEC; and divide by that, instead. That would force floating point division.