Since your function is simply counting how many seconds have elapsed, try this instead
Code:
static float time_in_seconds = 0;
static long prev_clock = 0;
long current_clock;
current_clock = clock();
if (current_clock < prev_clock)
time_in_seconds += ( (float) current_clock + 1 ) / CLOCKS_PER_SEC;
else
time_in_seconds = (float) current_clock / CLOCKS_PER_SEC;
return time_in_seconds;
You may want to use double instead of float because float does hot have enough precision from some time conversion operations.
btw, why won't my code format the way I want it to?
