Assuming you are running Unix, enable <sys / time.h>
timeval tim; gettimeofday(&tim, NULL); return tim.tv_usec;
If on Windows there is no good way to get microsecond resolution, moreover, it uses a different era. Only <windows.h> is required for this sample, I suppose.
FILETIME tim; GetSystemTimeAsFileTime(&tim); ULARGE_INTEGER ms; ms.LowPart = tim.dwLowDateTime; ms.HighPart = tim.dwHighDateTime; return ms.QuadPart * 10 + <nanoseconds from January 1, 1609 to January 1, 1970>; // ms represents how many 100s of nanoseconds
source share