Purpose

This function returns the number of milliseconds since the program started.

Header File

time.h

Prototype

clock_t clock (void);

Return Value

The number of milliseconds since the program began.

Example

#include <stdio.h>
#include <time.h>

int main () {
  clock_t Used;
  int i;
  i = 0;
  while (i < 100000000) ++i;  /* Delay loop */
  Used = clock ();
  printf ("The program ran for %i milliseconds",
          Used);
  return 0;
}

Output

The program ran for 961 milliseconds

Valid HTML 4.01 Transitional

Valid CSS

Site Icon Copyright © 1999-, jhyoung, revised 00/00/0