Running a Program for a Really Long Time and Using time.h

I'm trying to figure out what would happen if my program was left running for a long time.

At the moment I am using time.h (ctime) and the clock() function to make small measurements of time. What I want to know is what happens when the clock() function reaches the maximum value for a long int.

On this site it says that if the function fails it returns -1. So after it reaches the max value does it just start returning -1 or does it wrap and start over from zero.

If it just starts failing, is there some way to reset the timer. Is there some better way for me to make measurements of time?
The output of clock(3) wraps.

If you are running for that long, you probably don't need the precision of clock(). Or if you do, use clock_gettime() which uses a timespec type.

Could you explain a little bit more about clock(3). I didn't know that the function could take parameters. At least the reference says it doesn't.

I actually do need to precision because I am calculating a small dt for physics calculations. Where would I get the library that has clock_gettime()?
3 is the man pages section where clock() appears, not a parameter for clock(). foobar(n) is a common notation that means "the man page for foobar can be read by calling man n foobar".
Topic archived. No new replies allowed.