title: time.h library not working
body: <p>I am on the K&amp;R book and on exercise 3-1. I think my "time.h" library is broken.
  At first I thought my code was wrong but when I checked the solutions to the exercise
  on the net, they don't work either.</p>
  
  <p>The problem:</p>
  
  <p>The program output always shows zero seconds and the 'clocks' are sometimes are exchanged:</p>
  
  <pre><code>Output 1:
      Element -1 not found.
      binsearch() took 10000 clocks (0 seconds)
      Element -1 not found.
      binsearch2() took 20000 clocks (0 seconds)
  
  Output 2:
      Element -1 not found.
      binsearch() took 20000 clocks (0 seconds)
      Element -1 not found.
      binsearch2() took 10000 clocks (0 seconds)
  </code></pre>
  
  <p>The purpose of the program is to compare the two functions in terms of speed. How do I compare this?</p>
  
  <p>Here is the test code:</p>
  
  <pre><code> for ( i = 0, time_taken = clock(); i &lt; 100000; ++i ) {
      index = binsearch(n, testdata, MAX_ELEMENT);   /* all this code is duplicated with a
  }                                                     call to binsearch2 instead */
  time_taken = clock() - time_taken;
  
  if ( index &lt; 0 )
      printf("Element %d not found.\n", n);
  else
      printf("Element %d found at index %d.\n", n, index);
  
  printf("binsearch() took %lu clocks (%lu seconds)\n",
         (unsigned long) time_taken,
         (unsigned long) time_taken / CLOCKS_PER_SEC);
  </code></pre>
  
  <p>I tried this program in both Linux and Windows.</p>