I appear to be having trouble with clock(). I need to get precise time measurements (milliseconds would be nice, but I understand that that is not universally possible) and I would like to remain operating system unspecific. I decided to use clock(), but it has not been working as advertised.

The output of the following program is simply '0'. Yet when I increase the size of the for loop, the value becomes positive -- but is always an even number of seconds. Apparently, clock() is acting as if it has a resolution of seconds or worse. What do I do to make this work?

Code:
  1 #include <stdio.h>
  2 #include <time.h>
  3 
  4 int main(int argc, char** argv)
  5 {
  6     clock_t a = clock();
  7     int i; for(i = 0; i < 10000; i++);
  8     clock_t b = clock();
  9     printf("%f\n",(double)(b-a));
 10     return 0;
 11 }