C Code Timer or Clock

MaDHaVoK

Senior member
Mar 7, 2001
601
0
0
I am trying to create a timer.. that would start at 00:00:00:0 (HH:MM:SS:Tenth S) and go to 11:59:59.9 then reset to zero. My problem is I would like this to be accurate to the tenth of second... Any links where I could get help on this?

Thanks!
-Patrick
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
You could use a normal int or long and just increment it every 10th of a second (use nanosleep or usleep to keep time), but unless you're using a real-time scheduler you're not guaranteed it'll be perfect, you should use gettimeofday calls to verify how long you slept.
 

singh

Golden Member
Jul 5, 2001
1,449
0
0
It is very likely that any solution to your problem is going to be very Operating-System specific.