How to get the current time in milliseconds in C Programming

kk-dev11 picture kk-dev11 · Dec 19, 2011 · Viewed 148.7k times · Source

Possible Duplicate:
How to measure time in milliseconds using ANSI C?
How can I get the Windows system time with millisecond resolution?

We want to calculate the time which a player have taken to finish the game. But with time.h we could only calculate in seconds. but that is not exact. Is it possible to get the time in milliseconds? and what is the %? to printf?

Answer

Alok Save picture Alok Save · Dec 19, 2011

There is no portable way to get resolution of less than a second in standard C So best you can do is, use the POSIX function gettimeofday().