delta time for animation

I have a timer function that calls on a function to draw an object at a certain time. I get the time using this function:
time_elapsed = (clock()-startTime)/CLOCKS_PER_SEC;

My timer function calls itself again every 40ms seconds.

Problem is that the time_elapsed reported is smaller than real time. so even when 1 second has passed… time_elapsed thinks its 0.4 seconds

For a start don’t use clock() because it returns the time the process has used not current time.

try QueryPerformanceCounter or timeGetTime or some other method which will return current time in some way.

Matt